Our lab has a lot of different unix boxes, with different hardware, and I'm assuming (perhaps wrongly) that by setting a per-user package installation directory, the packages will only work on one type of hardware. Our systems are all set up to share the same home directory (and, thus, the same .Renviron file) -- so, is there a way to set, in the .Renviron file, per-computer or per-hardware settings? The idea is to have a different package installation directory for each computer (e.g. "~/R/computer1/packages" and "~/R/computer2/packages". Thoughts? Ideas? Thanks! --j -- Jonathan A. Greenberg, PhD Postdoctoral Scholar Center for Spatial Technologies and Remote Sensing (CSTARS) University of California, Davis One Shields Avenue The Barn, Room 250N Davis, CA 95616 Cell: 415-794-5043 AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307
The script .Rprofile evaluates R code on startup. You could use that to test for various environment variables. Alternatively, use Unix shell scripts to set system environment variables to be used in a generic .Renviron. See help(Startup) for more details. /Henrik On Sun, Jan 25, 2009 at 11:22 AM, Jonathan Greenberg <greenberg at ucdavis.edu> wrote:> Our lab has a lot of different unix boxes, with different hardware, and I'm > assuming (perhaps wrongly) that by setting a per-user package installation > directory, the packages will only work on one type of hardware. Our systems > are all set up to share the same home directory (and, thus, the same > .Renviron file) -- so, is there a way to set, in the .Renviron file, > per-computer or per-hardware settings? The idea is to have a different > package installation directory for each computer (e.g. > "~/R/computer1/packages" and "~/R/computer2/packages". > > Thoughts? Ideas? Thanks! > > --j > > -- > > Jonathan A. Greenberg, PhD > Postdoctoral Scholar > Center for Spatial Technologies and Remote Sensing (CSTARS) > University of California, Davis > One Shields Avenue > The Barn, Room 250N > Davis, CA 95616 > Cell: 415-794-5043 > AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307 > > ______________________________________________ > 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. >
Jonathan Greenberg wrote:> Our lab has a lot of different unix boxes, with different hardware, and > I'm assuming (perhaps wrongly) that by setting a per-user package > installation directory, the packages will only work on one type of > hardware. Our systems are all set up to share the same home directory > (and, thus, the same .Renviron file) -- so, is there a way to set, in > the .Renviron file, per-computer or per-hardware settings? The idea is > to have a different package installation directory for each computer > (e.g. "~/R/computer1/packages" and "~/R/computer2/packages". > > Thoughts? Ideas? Thanks!You would certainly want to look at altering the library path on R startup using the RProfile.site file (see ?Startup). You R code could use bits of info from the R variables .Platform and .Machine, plus some environment variables for UNIX platform info. As an example of altering the library path, this is what I have used in the past for my personal .Rprofile file: ### Add development R versions to the library path first devlib <- paste('~/Rlib',gsub(' ','_',R.version.string),sep='/') if (!file.exists(devlib)) dir.create(devlib) x <- .libPaths() .libPaths(c(devlib,x)) rm(x,devlib) So when I start up the latest development version of R, this is what is set: $ /home/hornerj/R-sources/trunk/bin/R --quiet > .libPaths() [1] "/home/hornerj/Rlib/R_version_2.9.0_Under_development_(unstable)_(2008-10-14_r46718)" [2] "/home/hornerj/R-sources/trunk/library" But with the latest ubuntu R release: $ R --quiet > .libPaths() [1] "/home/hornerj/Rlib/R_version_2.8.1_(2008-12-22)" [2] "/usr/local/lib/R/site-library" [3] "/usr/lib/R/site-library" [4] "/usr/lib/R/library" Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner