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

From: Roman Luštrik <romunov_at_gmail.com>
Date: Thu, 24 Jun 2010 04:14:00 -0700 (PDT)

I'm sorry, I don't understand your problem to the detail so my suggestion may be waaay off, but how's this? You can see in vector vec - all ok values except where there's an error.

n <- 10
vec <- rep(NA, n)
for (j in 1:n)
{tryCatch(ifelse(j==5, vec[j] <- j, j), finally=print("oh dear"))} vec

Cheers,
Roman

On Thu, Jun 24, 2010 at 1:06 PM, Paul Chatfield [via R] < ml-node+2266760-1183296220-76072_at_n4.nabble.com<ml-node%2B2266760-1183296220-76072_at_n4.nabble.com>
> wrote:

> I've had a look at the conditions in base and I can't get the ones to work
> I've looked at but it is all new to me.
>
> For example, I can work the examples for tryCatch, but it won't print a
> finally message for me when I apply it to my model. Even if I could get
> this to work, I think it would still cause a break e.g.
> for (j in 1:10)
> {tryCatch(ifelse(j==5, stop(j), j), finally=print("oh dear"))}
>
> Thanks for the suggestion though - any others?
>
> ------------------------------
> View message @
> http://r.789695.n4.nabble.com/How-to-say-if-error-tp2266619p2266760.html
> To unsubscribe from Re: How to say "if error", click here< (link removed) >.
>
>
>

-- 
In God we trust, all others bring data.

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

	[[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.
Received on Thu 24 Jun 2010 - 13:14:12 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