All the R packages installed on this Linux machine are installed in /usr/lib/R/library
. I want to move these packages to another location, such as /home/username/.R_libs
. I not only want to install packages in this new location, but I want to migrate all the previously installed packages to that location.
The output of .libPaths()
is:
[1] "/home/username/.R_libs" "/usr/lib/R/library"
However, if I just move all the packages, like so:
sudo mv /usr/lib/R/library/* /home/username/.R_libs/
R cannot start anymore as it seems unable to find the base package.
As for environment variables, $R_LIBS
is set to /home/username/.R_libs
, while $R_HOME
and $R_LIBS_USER
are unset in the shell. However, for some reason:
> Sys.getenv("R_LIBS")
[1] "/home/username/.R_libs"
> Sys.getenv("R_HOME")
[1] "/usr/lib64/R"
> Sys.getenv("R_LIBS_USER")
[1] "~/R/x86_64-pc-linux-gnu-library/3.4"
Note that ~/R/x86_64-pc-linux-gnu-library/3.4
does not exist and I do not want to create it, I want to only use /home/username/.R_libs
.
In short, I want that from now on R will only consider /home/username/.R_libs
and always install libraries to (or read libraries from) that location without asking for confirmation or additional options.
The best option, if I understood this correctly, would probably to move only the non-base packages, so the packages that were manually installed. Is this possible? Can this be done? Note that I'd prefer not to have to uninstall then reinstall all packages,