有没有人可以帮助 R 错误 while (x <= 100) { : 参数长度为零

  • 本文关键字:参数 帮助 没有人 错误 while r
  • 更新时间 :
  • 英文 :

x = 0
while (x <= 100){
x = x + sample(1:6,1,replace = F)
ladder.bottom = c(1,4,9,21,28,36,51,80)
ladder.top = c(38,14,31,42,84,44,67,100)
chute.bottom = c(6,11,19,24,26,53,60,73,75,78)
chute.top = c(16,49,62,87,47,56,64,93,95,98)
w = which(ladder.bottom == x)
t = which(chute.top == x)
if (length(w) >= 0){
x = ladder.top[w]
print(x)
}else if (length(t) >= 0){
x = chute.bottom[t]
print(x)
}else {
print(x)
next
}
}

返回

[1] 14
numeric(0)
Error in while (x <= 100) { : argument is of length zero

和我不知道为什么

if (length(w) >= 0)else if (length(t) >= 0)中,将>=替换为>

相关内容

最新更新