arshad
arshad

Reputation: 437

Cannot add new library path to .libPaths()

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"
> 

Upvotes: 1

Views: 980

Answers (2)

hello_friend
hello_friend

Reputation: 5788

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()))
}

Upvotes: -1

Kamil Bartoń
Kamil Bartoń

Reputation: 1562

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.

Upvotes: 3

Related Questions