[R] error logging

Gabor Grothendieck ggrothendieck at gmail.com
Tue Dec 29 05:20:08 CET 2009


Try this:

logfile <- file("logfile")
open(logfile, "w")
sink(logfile, type = "message")
1/"a"  # generate an error


On Mon, Dec 28, 2009 at 11:11 PM, Nick Torenvliet
<nick.torenvliet at gmail.com> wrote:
> Yet another question...
>
> I'm wondering if there is a built in facility to log errors.   I've got this
> statement that gives me verbose DBI errors as they come up (to standard
> output), but I'd like to trap and log them to a file as I running about
> 3000000 sql statements through this particular piece of code and I'd like to
> keep the loop going and deal with all the errors once the bulk of it has
> been processed.
>
>        atmpt <- try(dbGetQuery(con,sql))
>        options(show.error.messages = TRUE)
>        if(inherits(atmpt, "try-error")){
>
>        }
>
> The R docs aren't structured in the way I'm used to(I will get the hang of
> it)... so I'm more than willing to ?theDesiredCommand at the R - prompt...
> if you'd lead me in the right direction.
>
> Thanks again!
>
> Nick
>
>        [[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.
>




More information about the R-help mailing list