8

I'm setting up R/RStudio on a new Windows 10 machine; first time setting it up in a non-UNIX environment, so bear with me.

From my previous experience with R/RStudio under Linux and macOS, I wanted to setup separate libraries for system and user, i.e., that the Packages pane in RStudio would show both a User Library AND a System Library.

I specified the R_LIBS_USER environment variable for my account as C:\Users\[user name]\Documents\R\win-library\3.5.

When running R/RStudio, the .libPaths() are as follows:

> .libPaths()
[1] "C:/Users/[user name]/Documents/R/win-library/3.5"    
[2] "C:/Program Files/R/R-3.5.0/library"

This is pretty much what I wanted: the first library path being the default User Library, and the second path being the System Library. I'm able to install packages at will, and they are per default located inside the User Library.

HOWEVER, the Packages pane in RStudio does NOT show two separate libraries for the User Library and the System Library. Instead, all packages (aside from base) are shown under System Library; including the packages from my User Library. My question now is:

Is there a way to tell R/RStudio that my User Library and my System Library are two separate entities, which should be visually separated in RStudio's Packages pane?

Note: I'm aware this is likely a mere "cosmetic" issue; but it still bothers me! Also, I'm not sure if this is a pure R or an RStudio issue, so I tagged both.

EDIT: I also noticed that the System Library (C:/Program Files/R/R-3.5.0/library) is not available as drop-down option when installing new packages inside the Packages pane.

--

> devtools::session_info()
Session info --------------------------------------------------------------
 setting  value                       
 version  R version 3.5.0 (2018-04-23)
 system   x86_64, mingw32             
 ui       RStudio (1.1.453)           
 language (EN)                        
 collate  Nothing to worry about
 tz       This neither               
 date     2018-06-08                  

Packages ------------------------------------------------------------------
 package   * version date       source        
 base      * 3.5.0   2018-04-23 local         
 compiler    3.5.0   2018-04-23 local         
 datasets  * 3.5.0   2018-04-23 local         
 devtools    1.13.5  2018-02-18 CRAN (R 3.5.0)
 digest      0.6.15  2018-01-28 CRAN (R 3.5.0)
 graphics  * 3.5.0   2018-04-23 local         
 grDevices * 3.5.0   2018-04-23 local         
 memoise     1.1.0   2017-04-21 CRAN (R 3.5.0)
 methods   * 3.5.0   2018-04-23 local         
 stats     * 3.5.0   2018-04-23 local         
 tools       3.5.0   2018-04-23 local         
 utils     * 3.5.0   2018-04-23 local         
 withr       2.1.2   2018-03-15 CRAN (R 3.5.0)
 yaml        2.1.19  2018-05-01 CRAN (R 3.5.0)
Supertasty
  • 296
  • 2
  • 9

2 Answers2

0

I had exactly the same issue. In my case the cause was using a substituted drive for the user libraries:

> subst
F:\: => C:\data\flash drive

Setting R_LIBS_USER to F:/[...] shows the cosmetic error, using C:/data/flash drive/[...] works.

Thorsten
  • 196
  • 4
  • 8
0

In my case, Sys.getenv("R_LIBS_USER") is as follow:

"C:\\Users\\USERNAME\\AppData\\Local/R/win-library/4.2"

This path includes two backslashes, so this was causing the environment variable to not be recognized correctly. Next I searched for a place to put .Renviron as follows

R.home(component = "etc")

I created .Renviron (or Renviro.site) in that folder and saved it with the following in the contents and it worked.

R_LIBS_USER=C:/Users/${USERNAME}/AppData/Local/R/win-library/%v
nissinbo
  • 1
  • 1