[R] catch error/warning message in a loop

Spencer Graves spencer.graves at pdf.com
Mon Jun 2 21:44:40 CEST 2003


	  ?warnings asserts, " `warnings' prints the top-level variable 
'last.warning' in a pleasing form."

	  Have you tried something like "cat(i, last.warning)"?

hth.  spencer graves

array chip wrote:
> cat can only catch the error message promptly, but
> seems not able to catch the warning message promptly.
> Can anyone point out how i can catch the warning
> message in a loop?
> 
> 
> --- Spencer Graves <spencer.graves at PDF.COM> wrote:
> 
>>	  With situations like this, I often include
>>something like "cat(i, 
>>'')" in the loop (where "i" is the index of the
>>loop).
>>
>>	  If I'm writing a function to be used by others, I
>>might use "try", as 
>>described, e.g. in Venables and Ripley (2000) S
>>Programming (p. 48).
>>
>>hth.  spencer graves
>>
>>array chip wrote:
>>
>>>Hi, I am running cox regreesion (coxph) on a large
>>>number of independent variables, one variable at a
>>>time, using loop. At some point of the loop, the
>>
>>cox
>>
>>>regression stopped due to some errors. How can I
>>
>>know
>>
>>>at which variable the cox regression stopped so
>>
>>that I
>>
>>>can pinpoint the variable that causes the problem?
>>
>>I
>>
>>>guess this is not unique to cox regression, it is
>>
>>the
>>
>>>problem of catching the error/warning message
>>
>>promptly
>>
>>>in a loop.
>>>
>>>tahnks
>>>
>>>__________________________________
>>>

>>
>>to Outlook(TM).
>>
>>>______________________________________________
>>>R-help at stat.math.ethz.ch mailing list
>>>
>>
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 
>>
> 
> 
> __________________________________
> Do you Yahoo!?

> http://calendar.yahoo.com




More information about the R-help mailing list