[R] Keeping track of occurrence of warning message

Spencer Graves spencer.graves at pdf.com
Thu Jul 17 11:23:05 CEST 2003


Have you tried setting "options(warn=1)"?  I don't know if this will 
help, but I saw it on a related thread recently.

spencer graves

Tan Chuen Seng wrote:
> Hi Laurent,
> 
> Sorry to trouble you again. I have little idea how to get R to know if a
> warning has taken place. I tried using last.warning as I think it was
> what you suggested. But still track.warning is NULL although there are
> warnings. The code goes something like this:
> 
> w1<-0
> track.warning<-NULL
> ....
> if(length(last.warning)>w1){
> track.warning<-c(track.warning,data.no)
> }
> 
> It seems to me that length(last.warning)==0 throughout the running of
> the program although in the end there are still errors.
> 
> Please advice. Thanks for your help.
> 
>>From chuen seng
> 
> 
> -----Original Message-----
> From: Laurent Gautier [mailto:laurent at cbs.dtu.dk] 
> Sent: Wednesday, July 16, 2003 3:34 PM
> To: Tan Chuen Seng
> Subject: Re: [R] Keeping track of occurrence of warning message
> 
> 
> On Tue, Jul 15, 2003 at 05:51:32PM +0800, Tan Chuen Seng wrote:
> 
>>Hi Laurent,
>>
>>Thanks for the suggestion. However I am not too sure how to access
>>this last.warning while in the loop. From my understanding, I can't 
>>get dimensions from a list.
> 
> 
> l <- list(a=1:2, b=letters[1:5])
> length(l)
> lapply(l, length)
> 
> ...if it answers your question....
> 
> 
> 
> 
>>Please advice.
>>
>>>From chuen seng
>>
>>-----Original Message-----
>>From: Laurent Gautier [mailto:laurent at cbs.dtu.dk]
>>Sent: Tuesday, July 15, 2003 3:17 PM
>>To: Tan Chuen Seng
>>Cc: r-help at stat.math.ethz.ch
>>Subject: Re: [R] Keeping track of occurrence of warning message
>>
>>
>>On Tue, Jul 15, 2003 at 02:58:10PM +0800, Tan Chuen Seng wrote:
>>
>>>Hi there,
>>>
>>>I am interested if there is anyway to keep track of the occurrence
>>>of
>>>warning message.
>>>
>>>I know that warnings will only be printed out at the end of the 
>>>program if warn=0. However I am also interested at which particular 
>>>set of data does the warnings occur too. This is because I am 
>>>running 1000 data, so if there are 2 or 3 data that give warnings, I
>>
> 
>>>would like to know which are the ones out of the 1000 data.
>>>
>>>I tried using the following code in the program to indicate where
>>>the
>>>warning occur but was unable to get anything recorded although the
>>>warnings() gave me 12 messages.
>>>
>>>track.warning<-NULL
>>>....
>>>if(options("warn")$warn>=0){
>>>track.warning<-c(track.warning,data.no)
>>>}
>>>
>>>
>>>Your help is greatly appreciated. Thanks.
>>>
>>>>From chuen seng
>>>
>>>	[[alternative HTML version deleted]]
>>>
>>>______________________________________________
>>>R-help at stat.math.ethz.ch mailing list 
>>>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>>
>>
>>One way to do things is to have a list to store warnings has you hit
>>them in you loop: you can access what is the list last.warning.
>>
>>
>>
>>Hopin' it helps,
>>
>>
>>
>>L.
>>
>>
> 
>




More information about the R-help mailing list