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

From: Paul Chatfield <p.s.chatfield_at_reading.ac.uk>
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,

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

-- 
View this message in context: http://r.789695.n4.nabble.com/How-to-say-if-error-tp2266619p2266782.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.
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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive