Why does R have multiple folders for Libraries?

Asked

Viewed 28 times

1

I upgraded the version of R to 4.0 and am having problems with some libraries.

Trying to fix it, I found the command .libPaths()

> .libPaths()
[1] "/home/usuario/R/x86_64-pc-linux-gnu-library/4.0" "/usr/local/lib/R/site-library"                    
[3] "/usr/lib/R/site-library"                           "/usr/lib/R/library" 

I was curious, why does R have four folders for libraries? In addition to the version folders (.... linux-gnu-library/3.6)

1 answer

2


Prior note: All translations Deepl Translate and Google Translate, edits by me.

The explanation can be found in R itself but first see this user response Dirk Eddelbuettel dated July 17, 2016 to a question on Stackoverflow in English, my emphasis.

See help(Startup) for the full and Detailed Treatment. On Debian and Ubuntu we have been Setting These three Directories as the default for well over to Cade. As it is set via R_LIBS_SITE here, this is the variable you need to alter here. In general, you need to override the variable holding the value and you may not know ex ante which one that is.

In Portuguese, my emphasis.

See help(Startup) for complete and detailed treatment. In Debian and Ubuntu we have been setting these three directories as the default there are over a decade. How is defined by R_LIBS_SITE, is this the variable that needs to be changed. In general, it is necessary to undo the variable that holds the value and may not know ex ante which one of them is is.

Actually, in the file /etc/R/Renviron, almost at the end, we can see where these directories are defined. Note the dates of the edits and, above all, the comment to the first.

# edd Apr 2003  Allow local install in /usr/local, also add a directory for
#               Debian packaged CRAN packages, and finally the default dir 
# edd Jul 2007  Now use R_LIBS_SITE, not R_LIBS
R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'}

The comment on the first line above can be divided into three, each part with the reason to include each of the three directories.

  1. Allow local install in /usr/local;
  2. add a directory for Debian Packaged CRAN Packages;
  3. the default dir.

In English.

  1. Allow local installation in /usr/local;
  2. add a directory for CRAN packages prepared for Debian;
  3. the default directory.

R version and operating system.

rui@rui:~$ R -q -e 'sessionInfo()'
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=pt_PT.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=pt_PT.UTF-8        LC_COLLATE=pt_PT.UTF-8    
 [5] LC_MONETARY=pt_PT.UTF-8    LC_MESSAGES=pt_PT.UTF-8   
 [7] LC_PAPER=pt_PT.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=pt_PT.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.2
> 
> 
  • Excellent! Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.