我正在练习 R 编程课程的讲座,在他演示 tapply() 函数的其中一个讲座中,我只是复制粘贴了讲座中教授的内容,但出现语法错误
x <- c(norm(10),runif(10), rnorm(10,1))
f <- g1(3,10)
tapply(x, f, mean)
结果应如下所示
tapply(x, f, mean)
1 2 3
0.1144464 0.5163468 1.2463678
但我得到的是一个错误值
x <- c(norm(10),runif(10), rnorm(10,1))
Error in norm(10) : 'A' must be a numeric matrix
f <- g1(3,10)
Error: could not find function "g1"
tapply(x, f, mean)
Error in tapply(x, f, mean) : object 'f' not found