1

Hello I am trying to add a new path to .libPath() in RStudio in Windows. But it doesn't get added to it. Can someone please help me.

> .libPaths()
[1] "C:/Users/ars/Documents/R/R-3.5.1/library"
> .libPaths(c(.libPaths(), "C:/Users/ars/Documents/R/win-library/3.4/"))
> .libPaths()
[1] "C:/Users/ars/Documents/R/R-3.5.1/library"
> 

2 Answers 2

3

Remove the trailing slash. From ?.libPaths:

How paths new with a trailing slash are treated is OS-dependent. On a POSIX filesystem existing directories can usually be specified with a trailing slash: on Windows filepaths with a trailing slash (or backslash) are invalid and so will never be added to the library search path.

2
  • This has fixed the issue
    – arshad
    Commented Dec 24, 2018 at 4:40
  • @arshad if this is fixed, please consider to "accept" as answer.
    – zx8754
    Commented Jan 11, 2019 at 13:27
-1

Insert your desired path in quotes assigned to the path_to_libraries variable:

path.expand("~")
.First <- function() {
  path_to_libraries <- "" 
  .libPaths(c(path_to_libraries, .libPaths()))
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.