Crt Crt - 2 months ago 28
R Question

.libPaths() not changing

I have set R_LIBS in my .bash_profile to

export R_LIBS=/lib/R-3.3.0


and when I
echo $R_LIBS
, it returns
/lib/R-3.3.0
but, when I start R and type
.libPaths()
I get
/Software/R
.

What is going wrong?

Thanks

Answer

You want R_LIBS_USER:

$ Rscript -e 'print(.libPaths())'
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"   
[3]            "/usr/lib/R/library"           
$ R_LIBS_USER="/tmp" Rscript -e 'print(.libPaths())'
[1]                    "/tmp"  "/usr/local/lib/R/site-library" 
[3] "/usr/lib/R/site-library"             "/usr/lib/R/library" 
$ 

We see that adding one value to R_LIBS_USER adds a fourth directory to the three I get by default on my system.

Comments