libPath contains unwanted directory

I am trying to update my libPath() which is currently shown as:

> .libPaths()
[1] "E:/Backup/OneDrive/Documents/R/win-library/4.1" "C:/Program Files/R/R-4.1.2/library

I have a recollection of, many moons ago, following the instructions in How to Change the Default Library in Rstudio to a Different Default Library or Custom Library to update Rprofile, but this code is no longer there.

I have deleted C:\Program Files\R * and reinstalled R; deleted my Rstudio installation, renamed C:\Users\IanWo\AppData\Local\RStudio (old) and C:\Users\IanWo\AppData\Local\RStudio-Desktop (old), and reinstalled Rstudio, but still this persists.

The only WIndows environment variable defined is RTOOLS40_HOME=C:\rtools40 but a Sys.getenv() reveals also:

R_DOC_DIR                     C:/PROGRA~1/R/R-4.1.2/doc
R_HOME                        C:/PROGRA~1/R/R-4.1.2
R_LIBS_USER                   E:/Backup/OneDrive/Documents/R/win-library/4.1
R_USER                        E:/Backup/OneDrive/Documents

which I assume is somehow related to this.

Clearly, I've neglected to clean up something, but I'm at a loss to what it might be.

Any suggestions?

You can change the default library folder by setting your R_LIBS_SITE environmental variable in a .Reviron or .Rprofile file. For example:

# In a .Renviron file you can set it by adding a line like this one with the desired location 
R_LIBS_SITE="C:\\Program Files\\R\\R-4.1.2\\library"

For a more detailed explanation, you can read this blog post

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.