default R personal library location is null

后端 未结 3 1296
感情败类
感情败类 2020-12-30 08:01

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

相关标签:
3条回答
  • 2020-12-30 08:01

    On your computer, your current library is named after your R version.

    For instance, my current lib is :

    .libPaths()
    [1] "/home/colin/R/x86_64-pc-linux-gnu-library/3.3"
    

    as my current R version is 3.3.

    So yes, every time you'll update R, you'll face this lib problem. Note that you can set the path to your old library with .libPaths(new = "path/to/your/lib") or copy and paste your old library in the new one.

    Colin

    0 讨论(0)
  • 2020-12-30 08:13

    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).

    0 讨论(0)
  • 2020-12-30 08:25

    I found that for me the most suitable solution was to edit /etc/R/Renviron.site:

    # nano /etc/R/Renviron

    And uncomment the line where it sets R_LIBS_USER environment variable.

    Et voilà!

    I can again use library(), require(), and install.packages() within R.

    0 讨论(0)
提交回复
热议问题