【发布时间】:2013-06-17 08:31:32
【问题描述】:
我正在尝试将我的移动平均函数应用于一个变量,如下所示:
Fonction.mm <- function(x)
{
filter(x, poids, sides=1, method="conv")
}
numero<-1:nrow(data)
tapply(numero, data$td, Fonction.mm)
data$td 是一个字符变量,有 2 个类别。
但这不起作用得到错误:
Error in tapply(numero, data$td, Fonction.mm) :
arguments must have same length
非常感谢!
【问题讨论】:
-
为我们提供
numero和data$td的示例数据。即使这样,错误也很明显。numero和data$td的长度必须相同。 -
td val 2 38.553 2 2.313 1 7.559 1 95.648 1 7.559
-
td val 2 38.553 2 2.313 1 7.559 1 95.648 1 7.559 val 是我做移动平均的数字变量。
-
numero是整体数据的行数
-
请编辑您的问题。