[R] customizing library locations for R in ubuntu

ravi rv15| @end|ng |rom y@hoo@@e
Thu May 8 21:39:40 CEST 2025


Hi,
In Windows, I follow a method with customized library locations that has worked for me when upgrading to new R versions.  I have not been able to follow the same method in Ubuntu. I would like to have help. Let me explain.
In windows, I add the following line:
.libPaths(c(“C:/Rownlib”,”C:/R/R-4.5.0/library”))
      in the file C:/R/R-4.5.0/etc/Rprofile.site

I have my own list of packages in the Rownlib folder and the packages that come with the R installation for the latest version in the second folder. When upgrading to a new R version, I just change the 2nd library location to that for the updated R version.
I am not able to follow the same method for ubuntu. I get:
> .libPaths()
[1] "/usr/lib/R/library"            "/usr/local/lib/R/site-library" "/usr/lib/R/site-library" 
I don’t understand the reason why the ubuntu R version has the 2nd and 3rd “site-library” locations. Can somebody explain?
I tried to add a new library location with
.libPaths(new="/home/rvi/Rownlib")
This did not succeed in adding the new library.
I then added the line:
.libPaths(c("/home/rvi/Rownlib","/usr/lib/R/library" ))
in the Rprofile.site file after running:
sudo gedit /usr/lib/R/etc/Rprofile.site
Even this made no difference.
I noticed then that ubuntu has another file  ~ etc/Renviron (this seems to be absent on windows). This perhaps has priority over what is in Rprofile.site.
I see the following in Renviron:
R_LIBS_USER=${R_LIBS_USER:-'%U'}
R_LIBS_SITE=${R_LIBS_SITE:-'/usr/local/lib/R/site-library:%S'}
If this is the way to go, I would like to have help in modifying these lines to include the location, "/home/rvi/Rownlib", as the 1st library location.
Apart from a solution, I would also appreciate explanations for why the library system in ubuntu is structured in the way it is.
Thanks, Ravi



More information about the R-help mailing list