Re: [R] try catch block

From: Stephen Tucker <brown_emu_at_yahoo.com>
Date: Tue, 17 Jun 2008 21:12:38 -0700 (PDT)


This is a useful reference on the tryCatch() function: http://www1.maths.lth.se/help/R/ExceptionHandlingInR/

I think something like this should work: xml <- tryCatch(xmlTreeParse(xmlTxt, useInternal=TRUE),

      error=function(err) xmlMalFormed())

How can I use the try catch block such that if this statement fails xml <- xmlTreeParse(xmlTxt, useInternal=TRUE)

then this statement is executed

xml <- xmlMalFormed()

?

This code does not work but assuming its somewhere along these lines: tryCatch(xml <- xmlTreeParse(xmlTxt, useInternal=TRUE), xml <- xmlMalFormed(f1))

-- 
View this message in context: http://www.nabble.com/try-catch-block-tp17938467p17938467.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.
______________________________________________
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 Wed 18 Jun 2008 - 04:46:51 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 Wed 18 Jun 2008 - 05:31:23 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