Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the R have two libraries by default?

Tags:

windows

r

This is the first one: C:\Program Files\R\R-3.4.1\library

There is another one: C:\Users\Asus\Documents\R\win-library\3.4

I installed R all by default. Some packages are in the first library and some are in the second one.

like image 632
Cheng YunQi Avatar asked Jul 10 '17 19:07

Cheng YunQi


1 Answers

By default, R use a system library where base packages are installed and a user library where packages are installed.

It is all defined in .libPaths() which is used by default by lib arg in install.packages (see help file) The first element of .libPaths() is used as default path for installing package. All paths are used to look for a package when you load them with library() with first path priority.

On my system, which is windows too, I have the same as you :

  • system library in the folder where R is installed
  • a user library in the Documents folder of my user.

you can see libPath help page here (or type ?.libPaths() in console) for how to tweek the default behaviour with environment variable.

like image 185
cderv Avatar answered Oct 16 '22 18:10

cderv