为不同的窗口和不同的变量执行一个移动平均值循环R中的运行平均值函数

问题描述

我想为不同的窗口和不同的变量执行一个移动平均值循环(工作室中的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.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.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)