Description Usage Arguments Examples
This function reassigns .libPaths() to the specified directory then tries to
load the package using base::library
. This is to ensure that package
depenedencies (and the package itself) are not loaded from other directories
in the search tree (.libPaths()
).
1 | library.loc(pkg, loc, ...)
|
loc |
directory to load from. |
... |
other arguments to pass to |
package |
name of package to load. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | cwd <- getwd()
dir1 <- paste0(cwd, "/dir1")
dir2 <- paste0(cwd, "/dir2")
dir.create(dir1)
dir.create(dir2)
# install gbm package with and without dependencies
install.packages("gbm", lib = dir1, dependencies = c("Depends", "Imports"))
install.packages("gbm", lib = dir2, dependencies = FALSE)
# try to load from the directory without dependencies
library.loc(gbm, loc = dir2)
# now try to load from the directory with dependencies installed
library.loc(gbm, loc = dir1)
# to see behaviour of base::library - restart R before running
.libPaths(c(dir1, dir2))
library(gbm, lib.loc = dir2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.