By default, R packages are installed into a user-specific library based on the contents of the
R_LIBS_USER environment variable (more details on this mechanism are here: http://stat.ethz.ch/R-manual/R-devel/library/base/html/libPaths.html).
When you are working in R outside RStudio, R will use the default location described in the above link, unless
R_LIBS_USER is set explicitly in one of the startup files: .Rprofile or Rprofile.site.
However, RStudio offers more flexibility, and will look in several places for
- The /etc/rstudio/rsession-profile file
- The user's bash profile
r-libs-usersetting in /etc/rstudio/rsession.conf
- The R startup files: .Rprofile or Rprofile.site
R_LIBS_USER is set in more than one place, the order of precedence is:
.Rprofile or Rprofile.site >
r-libs-user in rsession.conf > user bash profile > rsession-profile
RStudio will pick it up from any of those places, but if it’s in more than one spot, that’s the order of precedence. Additional details can be found in the Customizing Session Launches and User Library sections of the RStudio Server Pro administrator's guide.