where R packages are installed

find and change where R packages are installed

Here is how to quickly find out where R packages are installed. You can change the location where R packages are stored or loaded if necessary.

Where R packages are installed?

To detect where R stores packages after installing them by the function install.packages or from where they are loaded, you can use the libPaths function.

.libPaths()

#[1] "C:/MyPackages/R"                   "C:/Program Files/R/R-3.6.1/library"

The first path in the results ar the path that is used to store or load R packages.

 

Change where R stores packages

I prefer to install R packages in a directory that is easy to use for me. You might do that for two following reasons. The first reason is that you want to change where R stores packages after running function install.packages. The second reason is that you want to change a location from where R packages are loaded with functions required and library.

You can add this by specifying the path in the libPaths function in the R script. If you want to do that permanently, you can modify your Rprofile file.

.libPaths("C:/OtherPlace/R")

Below is how to locate your Rprofile.site file, and here is how to modify that.

Sys.getenv("R_PROFILE_USER")

 

What else?

I hope this post is helpful in your situation. If you are modifying your Rprofile, consider adding some libraries or other functionality that you want to load together with R. My first picks would be clipr package that is lightweight and help you copy data from Excel to R and vice versa.

Here is how to round numbers in R in the same way as in Excel.





Posted

in

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *