为什么R对象不能在函数或“for”循环中打印?
我有一个名为ddd的R矩阵。当我输入这个,一切正常:
i <- 1shapiro.test(ddd[,y])ad.test(ddd[,y]) stem(ddd[,y]) print(y)
对Shapiro Wilk,Anderson Darling和stem的调用全部工作,并提取相同的专栏。
如果我把这段代码放在“for”循环中,那么对Shapiro Wilk和Anderson Darling的调用就会停止工作,而stem&leaf调用和打印调用将继续工作。
for (y in 7:10) {
shapiro.test(ddd[,y])
ad.test(ddd[,y])
stem(ddd[,y])
print(y)}The decimal point is 1 digit(s) to the right of the |
0 | 0
0 | 899999
1 | 0[1] 7如果我尝试编写一个函数,会发生同样的事情。SW&AD不起作用。其他的电话呢。
> D <- function (y) {+ shapiro.test(ddd[,y])+ ad.test(ddd[,y]) + stem(ddd[,y]) + print(y) }> D(9)
The decimal point is at the |
9 | 000
9 |
10 | 00000[1] 9为什么不是所有的调用都以相同的方式运行?
摇曳的蔷薇