【发布时间】:2021-11-09 04:10:51
【问题描述】:
我是 R 的初学者,我试图通过 R Markdown 中数据框“七项全能”的每一列运行 Grubbs 测试。所以,我使用了一个 for 循环:
for (i in 1:ncol(heptathlon)) {
grubbs.test(heptathlon[ ,i], type = 10, opposite = FALSE, two.sided = FALSE)
}
但运行代码后它什么也不打印。我还尝试了一个while循环:
i <- 1
while (i <= ncol(heptathlon)) {
grubbs.test(heptathlon[ ,i], type = 10, opposite = FALSE, two.sided = FALSE)
i = i+1
}
同样的结果,它什么也不打印。我不确定可能缺少什么。任何帮助,将不胜感激。谢谢
【问题讨论】:
-
默认情况下,循环内不会打印任何内容。如果要打印值,请使用
print(grubbs.test(heptathlon[ ,i], type = 10, opposite = FALSE, two.sided = FALSE)) -
啊,明白了。不敢相信我忽略了这一点。谢谢!
标签: r