[R] Error Handling

jim holtman jholtman at gmail.com
Tue Jun 24 21:15:43 CEST 2008


On Tue, Jun 24, 2008 at 1:59 PM, Sit Yee Kong <sityeekong at hotmail.com> wrote:
> Hi All,
> The for-loop below stopped when error("Cannot get confidence intervals on var-cov components: Non-positive definite approximate variance-covariance") occurred.
> I assigned a row of NA values
> to the data frame "m1" manually and reset "j" in the for-loop every time error returned. I'm wondering if
> there is a function that can detect error or failure, so the for-loop WILL NOT stop and the NA values can be assigned automatically if specified condition met. This can solve my problem that I need to set the NA values manually and reset j in for-loop every time error returned. Doing this manually would be very tedious.
>  m1<-matrix(ncol=3,nrow=0)
> for (j in 1:1000){
>  fit<-lme(Expression~1,random=~1|MonkeyID, data=mydata1,subset=Probes==as.character(Probes_Blood_sub[j,"probe"]))
>  ci<-intervals(fit)$reStruct$MonkeyID^2
>  m1<-rbind(m1,ci)}
> Thanks,Sityee
> _________________________________________________________________
> The i'm Talkathon starts 6/24/08.  For now, give amongst yourselves.
>        [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

More information about the R-help mailing list