Re: [R] How to say "if error"

From: Paul Chatfield <>
Date: Thu, 24 Jun 2010 04:21:45 -0700 (PDT)

Thanks Roman - you're right it can do more than I thought. We're close now to solving it I feel. Essentially I'm trying to get the code below to work. If the condition is satisfied, it prints 2, but it doesn't save it in z. I want it to save it even though there's an error. Perhaps you can easily see what I'm missing,

z<-ifelse(tryCatch(lm(y~x), finally=print(2))==1, NA,lm(rnorm(10)~rnorm(10)))

View this message in context:
Sent from the R help mailing list archive at

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 24 Jun 2010 - 13:20:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 24 Jun 2010 - 13:30:35 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive