【发布时间】:2013-12-10 00:29:21
【问题描述】:
我是 R 的新手,我陷入了一个愚蠢的错误。虽然我发现了一些可以解决我的问题的问题,但我无法解决它。
ww <- waveMC_list[[5]]
sampling=44100
thresh=10
timer.output <- timer(ww, f=sampling, threshold=thresh,envt="abs",ksmooth=kernel("daniell",100))
i=0
min.length=0.05 # minimum length of segment
segmts=length(timer.output[[4]]) # total amount of segments to evaluate
segments <- list() # output of valid segments
starts=timer.output[[4]] # starting times
ends=timer.output[[5]] # ending times
for(i in 1:segmts)
{
if(i <= segmts)
{
while(starts[i] <= ends[i]) #print(TRUE)
{
if((ends[i]-starts[i])>min.length)
{
segments[[i]] <- env(WaveMC(cutw(ww, f=44100, from= starts[i], to=ends[i],plot=F), bit= 16, samp.rate=44100)
, f=44100, ksmooth=kernel("daniell",90),plot=F)
print(paste('check', i, sep=' '))
print(segmts)
#env("ACAWAVEFILE", f=44100, ksmooth=kernel("daniell",90))
}
i=i+1
}
}
}
Error in while (starts[i] <= ends[i]) { :
需要 TRUE/FALSE 的地方缺少值
【问题讨论】:
标签: r error-handling while-loop