Rollapply() backwards in R

别等时光非礼了梦想. 提交于 2019-12-11 12:15:39

问题


Is there a way to apply rollapply() backwards say from 100 to 1 instead of 1 to 100 or should I sort my data first and then apply rollaplly()?


回答1:


Try this

z = 1:100
#Normal rollapply
rollapply(z, 2, mean)

#Reverese
rollapply(z[length(z):1], 2, mean)


来源:https://stackoverflow.com/questions/24056809/rollapply-backwards-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!