Why should I create the directory "~ / R /% p-library /% v" manually with every update of R?

Every time R updated, I must reinstall the packages I use (from sources, so I need to recompile them for the new version). This is the correct, understandable behavior, so I call install.packages and I get an error because the directory for writing "~/R/%p-library/%v" exists, and all other directories in .libPaths() are under /usr/ and cannot be written by the user. This behavior is described on the link pages.

So, after receiving the installation error, I have to do this:

 > dir.create(Sys.getenv("R_LIBS_USER")) > .libPaths(Sys.getenv("R_LIBS_USER")) > install.packages(c("igraph","entropy",...)) 

My question is: how do people deal with this problem?

Create a directory manually after each update? (but isn't that tiring?)

Add a dir.create call to .Rprofile ? ( obviously not )

EDIT: I seem to remember that when I started using R , this library directory appeared without my action; but I could be wrong ...

+4
source share
1 answer

One thing you could try is to specify R_LIBS in the R_LIBS file in your $HOME$ directory, for example, I work on Windows, so the first line in my .REnviron is like R_LIBS="C:\Some\path\library" ,

Then, when you start upgrading with the main version, you can simply use:

 update.packages( lib.loc = .libPaths()[1] , checkBuilt = TRUE ) 

To find out your $HOME$ directory, use:

 Sys.getenv("HOME") 
+3
source

Source: https://habr.com/ru/post/1479027/


All Articles