[R] any statement equals to 'goto'?

Allan Engelhardt allane at cybaea.com
Tue Aug 31 22:11:09 CEST 2010


Sounds like you want

help("tryCatch") # Catch the error and do something
help("next")  # Go to the next value of the surrounding loop

Hope this helps a little.

Allan

On 31/08/10 19:34, karena wrote:
> I have the following code:
> -----------------------------------------------------------------------------------------------------
> result<- matrix(NA, nrow=1, ncol=5)
> for(i in 1:(nsnp-1)) {
>    for(j in (i+1):nsnp){
> tempsnp1<- data.lme[,i]
> tempsnp2<- data.lme[,j]
> fm1<- lme(trait~sex+age+rmtemp.b+fc+tempsnp1+tempsnp2+tempsnp1*tempsnp2,
> random=~1|famid, na.action=na.omit)
> fm2<- lme(trait~sex+age+rmtemp.b+fc+tempsnp1+tempsnp2, random=~1|famid,
> na.action=na.omit)
> result[1,1]<- i
> result[1,2]<- j
> result[1,3]<- colnames(data.lme)[i]
> result[1,4]<- colnames(data.lme)[j]
> result[1,5]<- 2*(summary(fm1)$logLik-summary(fm2)$logLik)
> if (i==1&  j==2) results<- result
> if (i!=1 | j!=2) results<- rbind(results, result)
> }
> -----------------------------------------------------------------------------------------------------
>
> after submitting this code, I got the error message saying "Error in
> MEEM(object, conLin, control$niterEM) :
> Singularity in backsolve at level 0, block 1", I know this might be some
> issue due to the missing values. what I want to do is to skip the 'bad'
> variable, for example, I got this error message when j=116, so I just wanna
> ignore variable116, is there a statement that can do this: when getting this
> error message 'Error in MEEM...........', directly goto the next variable?
>
> thank you,
>
> karena
>
>
>
>



More information about the R-help mailing list