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]]
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. >
** works as exponentiation for me:> 3**2[1] 9 On Tue, Dec 29, 2009 at 6:10 AM, Phil Spector <spector at stat.berkeley.edu> wrote:> Nancy - > ? Please notice that ** is not an R operator. The caret (^) is the > exponentiation operator in R. > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?- Phil > > > > On Tue, 29 Dec 2009, Nancy Adam wrote: > >> >> Hi everyone, >> I tried to write the code of computing R2 for a regression system but I >> failed. >> This is the code I use for computing RMSE: >> >> my_svm_model <- function(myformula, mydata, mytestdata) >> ? ? { >> ? ? mymodel <- svm(myformula, data=mydata) >> ? ? mytest <- predict(mymodel, mytestdata) >> ? ? error <- mytest - mytestdata[,1] >> ? ? -sqrt(mean(error**2)) >> >> ? ? } >> can anyone please tell me what I have to change to compute R2 instead of >> RMSE? >> >> Many thanks, >> Nancy >> _________________________________________________________________ >> >> >> ? ? ? ?[[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. >> > > ______________________________________________ > 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. >
Gabor Grothendieck wrote:> ** works as exponentiation for me: > >> 3**2 > [1] 9Yes, but see ?"**" that it is just documented in a note and has been deprecated in S since 20 years... Uwe Ligges> > On Tue, Dec 29, 2009 at 6:10 AM, Phil Spector <spector at stat.berkeley.edu> wrote: >> Nancy - >> Please notice that ** is not an R operator. The caret (^) is the >> exponentiation operator in R. >> - Phil >> >> >> >> On Tue, 29 Dec 2009, Nancy Adam wrote: >> >>> Hi everyone, >>> I tried to write the code of computing R2 for a regression system but I >>> failed. >>> This is the code I use for computing RMSE: >>> >>> my_svm_model <- function(myformula, mydata, mytestdata) >>> { >>> mymodel <- svm(myformula, data=mydata) >>> mytest <- predict(mymodel, mytestdata) >>> error <- mytest - mytestdata[,1] >>> -sqrt(mean(error**2)) >>> >>> } >>> can anyone please tell me what I have to change to compute R2 instead of >>> RMSE? >>> >>> Many thanks, >>> Nancy >>> _________________________________________________________________ >>> >>> >>> [[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. >>> >> ______________________________________________ >> 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. >> > > ______________________________________________ > 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.