Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

default R personal library location is null

Tags:

r

I updated my Ubuntu 16.04 machine to R 3.4.1. When installing the first non-required package (eg, lubridate), I received the message:

would you like to create a personal library 'null' to install packages into?

This occurred in both RStudio and the command-line R. I uninstalled r-base-core & reinstalled r-base and r-base-dev through apt-get, and still had problems.

I noticed that the /etc/R/ directory contained four fleeting files that existed temporarily during the installation process, but had vanished by the time apt-get install r-base r-base-dev completed. I reinstalled again to quickly grab and paste those files to the desktop. After re-installing again, I copied them into /etc/R/ with:

~/Desktop/temp$ sudo cp repositories.dpkg-new /etc/R/repositories
~/Desktop/temp$ sudo cp Rprofile.site.dpkg-new /etc/R/Rprofile.site
~/Desktop/temp$ sudo cp ldpaths.dpkg-new /etc/R/ldpaths
~/Desktop/temp$ sudo cp Makeconf.dpkg-new /etc/R/Makeconf

The second step was to uncomment the second like below, found in /etc/R/Renviron. Apparently this is a recent change in the r-base packaging by @dirk-eddelbuettel.

# edd Jun 2017  Comment-out R_LIBS_USER
#R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'}
##R_LIBS_USER=${R_LIBS_USER-'~/Library/R/3.4/library'}

I have a two-part question:

  1. Is the process above recommended, or should I have done something differently? (eg, along the lines of Setting R_LIBS & avoiding "Would you like to use a personal library instead?".)
  2. Are these two steps likely required for future R upgrades on this machine?
like image 654
wibeasley Avatar asked Jul 02 '17 18:07

wibeasley


1 Answers

You are close. The problem rests in the "commenting out" of those lines, made without checking compatibility. The same problem happens if you try to install a library manually within the REPL, eg using:

install.packages("survival")

With the difference that you get an "NA" error instead of "null".

Solution for future R upgrades, if you want minimal hassle:

  • Restore the /etc/R/Renviron to the package default, so that it won't ask for your input (or just be overwritten) next time R is upgraded

  • Add a Renviron in your home directory, eg $HOME/.Renviron, with the following content:

R_LIBS_USER="${HOME}/R/${R_PLATFORM}-library/3.4.1/"

Personally, each time R upgrades I reinstall all libraries with the new version. So I will modify that 3.4.1 with 3.4.2 or whatever new version I have, and then reinstall the libraries.

If you don't want to reinstall your libraries, you can try to remove the version subdirectory altogether, eg:

R_LIBS_USER="${HOME}/R/${R_PLATFORM}-library/

so that your old libraries will be immediately seen by R.

NB: I couldn't find a way to put the R version inside the Renviron, sadly, but this could be achieved using an .Rprofile instead (since that can contain R code).

like image 113
Fabio Avatar answered Oct 15 '22 01:10

Fabio