1961 年から 2009 年までの年次データを含む aux という動物園オブジェクトがあります。
x$nao x[, 2]
1961 -0.03 63.3
1962 0.20 155.9
1963 -2.98 211.0
20 年のスライディング ウィンドウを使用して、2 つの列の相関関係を計算したいと考えています。rollapply を使用しようとしていますが、機能しないようです。私はそれを行うためにいくつかの異なる方法を試しましたが、常に成功しませんでした...
> rollapply(aux,20, cor(aux[,1],aux[,2],method="pearson"))
Error in match.fun(FUN) : 'cor(aux[, 1], aux[, 2], method = "pearson")' is not a function, character or symbol
> rollapply(aux,20, cor,method="pearson")
Error in FUN(coredata(data)[posns], ...) : supply both 'x' and 'y' or a matrix-like 'x'
> rollapply(aux,20, cor)
Error in FUN(coredata(data)[posns], ...) : supply both 'x' and 'y' or a matrix-like 'x'
仕事のやり方を誰か教えてくれませんかrollapply
?
助けてくれてありがとう!