I'm trying to find the best way to setup R for my team. Because our institution has the user home directory on a network share, the R user library is defaulted to this network share. After some research, I found that setting R_LIBS_USER in the .Renviron file is most useful (like stated at the rstudio forums ) As stated in the same post, it doesn't automatically create this directory after installing a new version of R, so .libPaths() defaults to C:/Program Files/R/../.. (the R_LIBS_USER is ignored)
In the question below, the same problem is asked 6 years ago. The accepted answer is not helping because it suggests making a version-independent user library. I don't want these old packages in my library. Why do I have to create the directory "~/R/%p-library/%v" by hand on each R upgrade?
I also tried setting .libPaths in the .Rprofile, but using the .Renviron file feels more efficient, so I prefer using this. This also allows the users to use their own .Rprofile settings in their projects.
My current way of working is:
- .Renviron file
R_LIBS_USER=C:/Users/[user]/R/%p-library/%v
- Each user calls this command after a new R install
dir.create(Sys.getenv('R_LIBS_USER'), recursive = TRUE)
I want to know what's the best/cleanest setup for automatically creating the R_LIBS_USER folder, so reinstalling R doesn't need any manual actions that can be forgotten by the users.