[R] Problem setting TMPDIR on the fly
Benjamin Lloyd-Hughes
Benjamin.Lloyd-Hughes at benfieldgroup.com
Tue Oct 31 11:32:04 CET 2006
Sorted - sort of...
I've simply wrapped the invocation of R in a shell script along with the necessary environment variables. However, this is precisely the solution that I was hoping to avoid!
I can see why it would be inadvisable to switch TMPDIR mid way through a session, but wouldn't it be useful to able switch it on the way in?
As ever thanks for the help, cheers, Ben
-----Original Message-----
From: pd at pubhealth.ku.dk [mailto:pd at pubhealth.ku.dk] On Behalf Of Peter Dalgaard
Sent: 30 October 2006 17:08
To: Benjamin Lloyd-Hughes
Cc: Peter Dalgaard
Subject: Re: [R] Problem setting TMPDIR on the fly
"Benjamin Lloyd-Hughes" <Benjamin.Lloyd-Hughes at benfieldgroup.com> writes:
> Hi Peter,
>
> Thanks for the swift response!
>
> The problem is arising because I'm running R in batch mode through cron. As such I'd rather set all such environment variables explicitly and not make any assumptions about what variables maybe getting set on the way in. A typical call looks like this
>
> /usr/bin/R CMD BATCH --vanilla foo.R bar.Rout
>
> The first few lines of foo.R might run
>
> .libPaths(c("/usr/lib/R/library", "/eurotempest/software/src/R/packages"))
> Sys.putenv(TMPDIR = "/eurotempest/tmp/R/")
>
> Hence the problem.
>
> Is there a more sensible way to go?
I'd just set it on the command line, as in
TMPDIR="/eurotempest/tmp/R/" R
>
> -----Original Message-----
> From: pd at pubhealth.ku.dk [mailto:pd at pubhealth.ku.dk] On Behalf Of Peter Dalgaard
> Sent: 30 October 2006 16:33
> To: Benjamin Lloyd-Hughes
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] Problem setting TMPDIR on the fly
>
> "Benjamin Lloyd-Hughes" <Benjamin.Lloyd-Hughes at benfieldgroup.com> writes:
>
> > Hi folks,
> >
> >
> >
> > I'm having a spot of bother with tempdir(). If I set the environment
> > variable TMPDIR in my shell prior to invoking R it works as expected:
> >
> >
> >
> > > Sys.getenv("TMPDIR")
> >
> > TMPDIR
> >
> > "/eurotempest/tmp/R"
> >
> > > tempdir()
> >
> > [1] "/eurotempest/tmp/R/Rtmp0xY4XD"
> >
> >
> >
> > However if I don't set it prior to entry, but attempt to set it from
> > within the current session, the change is not detected/respected:
> >
> >
> >
> > > Sys.getenv("TMPDIR")
> >
> > TMPDIR
> >
> > ""
> >
> > > Sys.putenv(TMPDIR = "/eurotempest/tmp/R/")
> >
> > > Sys.getenv("TMPDIR")
> >
> > TMPDIR
> >
> > "/eurotempest/tmp/R/"
> >
> > > tempdir()
> >
> > [1] "/tmp/Rtmp9chsNX"
> >
> >
> >
> > Any ideas?
>
> You're not supposed to do that. There is one and only one tempdir per
> R session. This is used for storing stuff which R expects to be able to
> find again later, so it would be a bad thing just to switch it out.
>
> --
> O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
> c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
> (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
>
>
> ------------------------------------------------------------------------------
> This e-mail and its contents are intended for the use of the addressee(s) and may be confidential/privileged. No-one else may review, copy, disclose or otherwise use it or its contents. If you receive this e-mail in error, please contact the originator and delete it as soon as possible.
> Benfield Limited is authorised by the Financial Services Authority under the reference number 311884. Registered in England no 1170753. Registered office 55 Bishopsgate.
>
> Please refer to Benfield Limited's terms and conditions (www.benfieldgroup.com/terms) for a description of our services, duties and points of contact. Please review these terms and conditions at inception and renewal of all reinsurance and insurance contracts.
>
> Please note that our terms and conditions and interests in other companies may change over time and these changes will be reflected on the Benfield Limited website. The latest version of our terms and conditions supersedes all previous versions.
> ==============================================================================
>
>
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
------------------------------------------------------------------------------
This e-mail and its contents are intended for the use of the addressee(s) and may be confidential/privileged. No-one else may review, copy, disclose or otherwise use it or its contents. If you receive this e-mail in error, please contact the originator and delete it as soon as possible.
Benfield Limited is authorised by the Financial Services Authority under the reference number 311884. Registered in England no 1170753. Registered office 55 Bishopsgate.
Please refer to Benfield Limited's terms and conditions (www.benfieldgroup.com/terms) for a description of our services, duties and points of contact. Please review these terms and conditions at inception and renewal of all reinsurance and insurance contracts.
Please note that our terms and conditions and interests in other companies may change over time and these changes will be reflected on the Benfield Limited website. The latest version of our terms and conditions supersedes all previous versions.
More information about the R-help
mailing list