Lyman, Mark
2009-Mar-19 16:46 UTC
[R] How to set R_PROFILE conditional on batch or interactive mode
I am running R 2.8.1 on SUSE Linux. I would like to be able to set R_PROFILE to two different possibilities. One when R is called by R CMD BATCH and another any other time. Is this possible? Mark Lyman, Statistician Engineering Systems & Integration, ATK
Rolf Turner
2009-Mar-19 19:00 UTC
[R] How to set R_PROFILE conditional on batch or interactive mode
On 20/03/2009, at 5:46 AM, Lyman, Mark wrote:> I am running R 2.8.1 on SUSE Linux. I would like to be able to set > R_PROFILE to two different possibilities. One when R is called by R > CMD > BATCH and another any other time. Is this possible?I think so. In your .Rprofile have code like unto: if(interactive()) { # Do the non-batch thing } else { # Do the batch thing. } Haven't tested this, but. cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
Lyman, Mark
2009-Mar-19 21:25 UTC
[R] How to set R_PROFILE conditional on batch or interactive mode
Yes, thank you. That does the trick. Mark Lyman -----Original Message----- From: Rolf Turner [mailto:r.turner at auckland.ac.nz] Sent: Thursday, March 19, 2009 2:42 PM To: Lyman, Mark Cc: r-help at r-project.org Subject: Re: [R] How to set R_PROFILE conditional on batch or interactive mode On 20/03/2009, at 9:17 AM, Lyman, Mark wrote:> Thanks for the suggestion Rolf. Unfortunately, this uses the BATCH > profile when I use for example R CMD INSTALL. I would like the BATCH > profile to be used only when R CMD BATCH is used. Sorry, about the > vagueness of my question. > > I have found a way that approximates what I want to do. If I create a > new script file R2, with the only change from the regular R script > file > being that I set and export the R_PROFILE variable, I can use this new > script file when I want to run BATCH jobs. > > R2 --save --file=jobfileHmmm. Try: cargs <- commandArgs() mmm <- match("-f",cargs) if(is.na(mmm)) { # Do the non-batch thing. } else { # Do the batch thing. } Does that get you where you want to go? cheers, Rolf ###################################################################### Attention: This e-mail message is privileged and confidential. If you are not the intended recipient please delete the message and notify the sender. Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshal www.marshalsoftware.com ######################################################################