【发布时间】:2013-02-24 06:22:52
【问题描述】:
我一直在尝试运行此代码(在此处下方)并且收到消息“if (temp[ii] == 0) { 中的错误:需要 TRUE/FALSE 的缺失值”...
temp = c(2.15, 3.5, 0, 0, 0, 1.24, 5.42, 6.87)
tm = length(temp)
for (i in 1:tm){
if (temp[i] == 0) {
counter3 = 1
last = temp[i - 1]
for (ii in i + 1:tm){
if (temp[ii] == 0) {
counter3 = counter3 + 1
}
if (temp[ii] != 0) {
nxt = temp[i + counter3]
}
}
}
}
【问题讨论】:
-
如果你 a) 提到了语言,B) 修正了你的格式,可能会有所帮助。
-
-1 表示不搜索。此问题已在本站、R-help 等上多次回答。下次发问题前先搜索错误,您自己可能会更快地回答问题。
-
此问题已在此线程中得到解答:stackoverflow.com/questions/7355187/…