简体   繁体   中英

Obtaing the position of max in a rollapply type function in r

I'm trying to obtain the position of max value in a group, using rollapply function (zoo package).

What i'm trying to do is create the column "position.of.max.group.of.three":

在此处输入图像描述

What i tried to do:

It works:

df2$position.of.max.group.of.three = rollapplyr(df2$x, 3, which.max, fill = NA)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM