You might be better off just using the renv package.

To your question, you should probably be reading the R Installation and 
Administration manual.

Note that packages can be installed by the system administrator in *nix 
environments and the alternate libraries allow you to use some set of R 
packages without installing any in your personal library... if everyone is 
happy with this arrangement then you can have multiple users on the system 
using shared read-only package installations (installed by running sudo R for 
the sole purpose of installing system-wide contributed packages) without 
duplicating installs of the same package in multiple personal environments. 

However, it is actually more common than not for multiple users to want to run 
different versions of packages for reproducibility or bleeding edge features, 
in which case the premise of saving disk space this way is moot.

Given your habits, I can't see any reason for you to worry about keeping 
/usr/local/lib/R/site-library or /usr/lib/R/site-library intact in your library 
paths, but whatever local library path you do use, you will want to retain 
/usr/lib/R/library as an alternate because it contains the packages that are 
"built-in" to R.

On May 8, 2025 12:39:40 PM PDT, ravi via R-help <r-help@r-project.org> wrote:
>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
>
>______________________________________________
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to