[R] Setting hostname in the .Renvironment
Uwe Ligges
ligges at statistik.tu-dortmund.de
Mon Nov 21 15:12:56 CET 2011
On 21.11.2011 01:32, Jonathan Greenberg wrote:
> This is a follow-up to a question I asked a few years back. We have a pair
> of computers that share a common home directory (and therefor a common
> .Renviron) with identical hardware, but very different sets of libraries
> such that using a "shared" R_LIBS between two computers does not work.
> They both use this as the default library for user installations:
>
> '~/R/x86_64-pc-linux-gnu-library/2.13'
>
> I would like to mod the .Renviron in such a way so
>
> '~/R/hostname-1/x86_64-pc-linux-gnu-library/2.13'
> '~/R/hostname-2/x86_64-pc-linux-gnu-library/2.13'
>
> How can I modify my R_LIBS_USER in the .Renviron to match this? The
> hostname would need to be "dynamically" set based on which computer I log
> into, but I tried something like this:
>
> R_LIBS_USER="~/lib/R/library/"$HOSTNAME"_%p_%a_%o_R%V"
Depends on the shells you are using and where it is defined, but you
definitely need braces rather than quotes as in:
R_LIBS_USER="~/lib/R/library/${HOSTNAME}"
and I have to
export HOSTNAME ${HOSTNAME}
at first on the machines I am using to have it accessible for R.
Best,
Uwe Ligges
> and R did not resolve the $HOSTNAME environment variable even though I can
> (from bash) echo $HOSTNAME and it return the correct name.
>
> Thoughts? Thanks!
>
> --j
>
>
More information about the R-help
mailing list