Re: [R] Query about using optimizers in R without causing program to crash

From: Andrew Robinson <A.Robinson_at_ms.unimelb.edu.au>
Date: Mon 22 Jan 2007 - 20:53:00 GMT

Hi Lalitha,

Use

try()

or

tryCatch()

Cheers

Andrew

On Mon, Jan 22, 2007 at 12:43:28PM -0800, lalitha viswanath wrote:
> Hi
> I am a newbie to R and am using the lm function to
> fit my data.
> This optimization is to be performed for around 45000
> files not all of which lend themselves to
> optimization. Some of these will and do crash.
>
> However, How do I ensure that the program simply goes
> to the next file in line without exiting the code with
> the error
> "Error in lm.fit(x, y, offset = offset, singular.ok =
> singular.ok, ...) :
> NA/NaN/Inf in foreign function call (arg 4)"
> everytime it encounters troublesome data?
>
> I would greatly appreciate your input as it would
> avoid me having to manually type
> for fileId in (c(4351:46000)) { ... }
> for fileId in (c(5761:46000)) { ... }, etc...
>
> Thanks
> Lalitha
>
>
>
> ____________________________________________________________________________________
> Now that's room service! Choose from over 150,000 hotels
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.

-- 
Andrew Robinson  
Department of Mathematics and Statistics            Tel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia         Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

______________________________________________
R-help@stat.math.ethz.ch 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 Tue Jan 23 08:25:08 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 22 Jan 2007 - 21:30:33 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.