How can compute rolling window for standard deviation in R?

后端 未结 2 742
离开以前
离开以前 2021-01-16 11:29

I tried to download the stock price and compute the standard deviation in rolling window. I found the library PerformanceAnalytics but they only have the rollin

2条回答
  •  独厮守ぢ
    2021-01-16 11:59

    Try this:

    library(zoo)
    rollapplyr(1:10, 3, sd, fill = NA)
    ## [1] NA NA  1  1  1  1  1  1  1  1
    

    See ?rollapply for more info.

提交回复
热议问题