Whenever I change the library path order using the .libPaths()
function, it reverts back to the default if I restart R. How can I change this permanently? I am
find the Rprofile
file (no dot) in R installation folder
find -name Rprofile
#Getting something like:
#lib/R/library/base/R/Rprofile
Open the file and search for:
invisible(.libPaths(c(unlist(strsplit(Sys.getenv("R_LIBS"), ":")),
unlist(strsplit(Sys.getenv("R_LIBS_USER"), ":") )
)))
comment other paths and add your desired path
invisible(.libPaths(c(#unlist(strsplit(Sys.getenv("R_LIBS"), ":")),
#unlist(strsplit(Sys.getenv("R_LIBS_USER"), ":") )
"/home/users/username/R/4.0.1/lib/R/library" # desired path
)))
This can be useful also: (for .bashrc
file)
export R_LIBS='/home/users/username/R/4.0.1/lib/R/library'
export R_LIBS_USER='/home/users/username/R/4.0.1/lib/R/library'