Ubuntu removes .libPaths () in R

After installing RStudio, I ran:

library()

Warning message: libraries / usr / local / lib / R / site -library ',' usr / lib / R / site-library 'do not contain packages

Then I enter:

.libPaths()

[1] "/home/avalon/R/x86_64-pc-linux-gun-library/3.2"
[2] "/usr/local/lib/R/site-library"
[3] "/usr/lib/R/site-library"
[4] "/usr/lib/R/library"

How to remove [2] and [3] to prevent a warning message from appearing?

Expected Result:

.libPaths()

[1] "/home/avalon/R/x86_64-pc-linux-gun-library/3.2"
[4] "/usr/lib/R/library"
+4
source share
1 answer

Linux

The first thing to do is read the manpage on it ( ?.libPaths) and you will see:

'. libPaths' , R (, , ). 'new, unique(c(new, .Library.site, .Library)), . , .

( ). , , .Library.site. , (ergo "site" ) , "" , .

:

'. Library.site' "R_LIBS_SITE" ( ).

, - R ( R):

# in bash on the command line:
$ R_LIBS_SITE=" " R

# in R
R> .libPaths()
[1] "/usr/lib/R/library"

RStudio ~/.Renviron, , :

R_LIBS_SITE=" "

.libPaths():

R> .libPaths()
[1] "/usr/lib/R/library"

, :

R> .libPaths(c("/home/avalon/R/x86_64-pc-linux-gun-library/3.2", .libPaths()))
[1] "/home/avalon/R/x86_64-pc-linux-gun-library/3.2"
[2] "/usr/local/lib/R/site-library"
[3] "/usr/lib/R/site-library"
[4] "/usr/lib/R/library"

, , :

R> .libPaths( c(.libPaths()[c(1,4)]) )
[1] "/home/avalon/R/x86_64-pc-linux-gun-library/3.2"
[2] "/usr/lib/R/library"

(.. , ):

R> .libPaths(c("/home/avalon/R/x86_64-pc-linux-gun-library/3.2", .libPaths()[3]))
[1] "/home/avalon/R/x86_64-pc-linux-gun-library/3.2"
[2] "/usr/lib/R/library"

, , , .

+3

All Articles