【发布时间】:2016-07-06 17:37:02
【问题描述】:
我正在尝试在 RStudio 中完成随机排列测试并不断收到以下两个错误: 错误:评估嵌套太深:无限递归/选项(表达式=)? 总结期间出错:评估嵌套太深:无限递归/选项(表达式=)?
#create groups/data vectors
drinks = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
mosquito = c(27, 20, 21, 26, 27, 3, 24, 21, 20, 19, 23, 24, 28, 19, 24, 29, 18, 20, 17, 31, 20, 25, 28, 21, 27, 21, 22, 15, 12, 21, 19, 15, 22, 24, 19, 23, 13, 22, 20, 24, 18, 20)
#create function
rpermut = function(group, outcome, permutation){
diff = rep(NA, permutation)
for(i in 1:permutation){
outcome = sample(outcome)
diff[i] = mean(outcome[group==levels(group)[1]]) - mean(outcome[group==levels(group)[2]])}
diff
}
#adding values to function
mosrep = rpermut(group=drinks, outcome=mosquito, permutation=1000)
我不确定错误代码是什么意思,也不确定如何解决问题以使函数运行。我将非常感谢您能提供的任何帮助,说明我在哪里出错了!
【问题讨论】:
标签: r function error-code