rrstudiolibrary-path

how to set lib-paths in R to have a single directory which is "C:\Users\Username\Documents\..."


Win 7 64 bit machine R version 3.5.3 (2019-03-11)

Question: How do I set my library paths to have only one directory, namely: "C:/Users/Username/Documents/R/win-library/3.5" ?

I added .libPaths("C:/Users/Username/Documents/R/win-library/3.5") to RProfile.site

Set R_LIBS_USER and R_LIBS to: C:\Users\Username\Documents\R\win-library\3.5

R_LIBS_SITE:

[1] "C:\\Users\\Username\\Documents\\R\\win-library\\3.5"

yet when I start RStudio and input:

> .libPaths()
[1] "C:/Users/Username/Documents/R/win-library/3.5" "C:/Program Files/R/R-3.5.3/library"

I still end up with two library paths (as above).

Furthermore, in RStudio I am not able to set lib-paths to just "C:/Users/Username/Documents/R/win-library/3.5" with these steps:

> .libPaths("C:/Users/Username/Documents/R/win-library/3.5")
> .libPaths()
[1] "C:/Users/Username/Documents/R/win-library/3.5" "C:/Program Files/R/R-3.5.3/library" 
> .libPaths("C:/Program Files/R/R-3.5.3/library")
> .libPaths()
[1] "C:/Program Files/R/R-3.5.3/library"
> .libPaths("C:/Users/Username/Documents/R/win-library/3.5")
> .libPaths()
[1] "C:/Users/Username/Documents/R/win-library/3.5" "C:/Program Files/R/R-3.5.3/library"

An attempt to set lib-paths by editing .Renviron with:

> usethis::edit_r_environ()

Added .libPaths("C:\Users\Username\Documents\R\win-library\3.5") to and saved .Renviron file. This resulted in an R Message upon restarting R:

File C:/Users/Username/Documents/.Renviron contains invalid line(s) .libPaths("C:\Users\Username\Documents\R\win-library\3.5")

Thank you


Solution

  • Hong Ooi's answer: "You can't, and you don't want to, remove the base library location. That's where R's own packages live, and without them you can't use R."