[R] way to check if the evaluation of an expression returns an error?

From: Thomas Pujol <thomas.pujol_at_yahoo.com>
Date: Fri, 14 Dec 2007 14:10:52 -0800 (PST)


Is there a recommended or "good" way to check if the evaluation of an expression returns an error?    

  e.g.
var(NA)
  I wish var(NA) to return NA or "err", or some other value, even a text-string, but not an error message.        

  I am using a loop to load many samples of data and to perform analysis on each sample. On occasion, the function I execute returns an error message. (e.g. when all data is NA, etc). I wish for the loop to continue to execute, and to have the function return an NA or NULL rather then an error message.            


        [[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 Fri 14 Dec 2007 - 22:13:41 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 Fri 14 Dec 2007 - 23:30:19 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.