私は R プログラミングに関する講座の講義を練習していました。彼が tapply() 関数を実演する講義の 1 つで、講義で教えられていることをコピーして貼り付けただけですが、構文エラーが発生しました。
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