Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controversy of R_LIBS_USER path

Tags:

r

When I check the R environment I got:

> Sys.getenv("R_LIBS_USER")
[1] "~/R/x86_64-pc-linux-gnu-library/3.3"

But when I cd to the directory, there seems no this path at all:

dz33@ccis4240:~/R/x86_64-pc-linux-gnu-library$ ll -a
total 12
drwxr-xr-x  3 dz33 dz33 4096 Jul  2  2015 .
drwxr-xr-x  3 dz33 dz33 4096 Jul 10  2015 ..
drwxr-xr-x 64 dz33 dz33 4096 Mar 30 16:41 3.2

As you can see there is only /3.2 directory but /3.3. Does anybody know why and How to change to 3.2 or set up 3.3? It appears my R version is the latest:

> R.Version()
$platform
[1] "x86_64-pc-linux-gnu"

$arch
[1] "x86_64"

$os
[1] "linux-gnu"

$system
[1] "x86_64, linux-gnu"

$status
[1] ""

$major
[1] "3"

$minor
[1] "3.0"

$year
[1] "2016"

$month
[1] "05"

$day
[1] "03"

$`svn rev`
[1] "70573"

$language
[1] "R"

$version.string
[1] "R version 3.3.0 (2016-05-03)"

$nickname
[1] "Supposedly Educational"
like image 807
David Z Avatar asked Feb 06 '23 17:02

David Z


1 Answers

The R_LIBS_USER variable is optional and, if set, will be prepended to the library path (which is displayed by .libPaths()).

I may be in the minority but on the systems I look after I try to unset R_LIBS_USER so that I get

R> .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"  
[3] "/usr/lib/R/library"           
R> 

meaning that install.packages() et al will use a system-wide directory accessible by all users on the system --- which makes sense at work where we have multi-user systems. One thing to note is that you want your users to be members of a group with group-write permissions on that directory to be able to install (as long as you can trust your users).

Doing it this also does away with versioned directories (ie 3.2/ vs 3.3/) you observed.

Fuller details are in help(Startup).

like image 80
Dirk Eddelbuettel Avatar answered Feb 18 '23 11:02

Dirk Eddelbuettel