为不同窗口和不同变量的移动平均值(R中的runmean函数)执行循环
我想为不同窗口和不同变量的移动平均值(studio中的runmean函数)执行一个循环。你能帮帮我吗 以下是有关我的代码/数据的一些详细信息: 数据:(我有3个变量p,t,r),在这个例子中,我显示了来自r的数据。 r为不同窗口和不同变量的移动平均值(R中的runmean函数)执行循环,r,moving-average,R,Moving Average,我想为不同窗口和不同变量的移动平均值(studio中的runmean函数)执行一个循环。你能帮帮我吗 以下是有关我的代码/数据的一些详细信息: 数据:(我有3个变量p,t,r),在这个例子中,我显示了来自r的数据。 r [1]107.97745 83.65267 117.24017 194.20069 155.12351 104.32758 63.06476 [8] 171.83118 81.13054 108.77109 90.91269 83.37936 41.00922 63.7
[1]107.97745 83.65267 117.24017 194.20069 155.12351 104.32758 63.06476
[8] 171.83118 81.13054 108.77109 90.91269 83.37936 41.00922 63.76061
[15] 125.24803 71.68391 71.40551 103.68311 113.66882 67.30023 85.68183
[22] 65.74271 65.58126 171.03329 120.30353 125.47056 152.20812 129.43295
[29] 170.73123
```#
如果我使用移动平均函数(r中的runmean),我得到:
''dTaul'从一个问题中得到最好的,请考虑提供一个。使用例如dput
共享您的一些数据,并澄清您的函数来自哪个包,除非它是baseR函数。
[1] 107.97745 83.65267 117.24017 194.20069 155.12351 104.32758 63.06476
[8] 171.83118 81.13054 108.77109 90.91269 83.37936 41.00922 63.76061
[15] 125.24803 71.68391 71.40551 103.68311 113.66882 67.30023 85.68183
[22] 65.74271 65.58126 171.03329 120.30353 125.47056 152.20812 129.43295
[29] 170.73123
```#
if I use Moving average function (runmean in r) i obtain this:
```dta<-runmean(r, k=2)
```dta
Now I would like to compute at the one time for all variables (p,t,r) and for different windows (k=1,k=2,k=3,....k=9)the runmean.
RStudio
Thanks for your help.