以下是我的R脚本的一部分:
getPeaks = function(wl){
peaks = NULL
count = 1
for(i in 30:(length(wl)-30)){
now = as.numeric(wl[i])
before = max(as.numeric(wl[(i-1):(i-30)]))
after =max(as.numeric(wl[(i+1):(i+30)]))
if(now > before & now > after){
peaks = rbind(peaks, wl[i])
}
}
peaks}
该代码到达Peaks = NULL
行时停止运行。我得到标题中的错误消息:
如果(现在>之前&现在>现在>之后){:在需要TRUE / FALSE时缺少值
任何帮助将不胜感激!