I am developing a package that requires the namespace of another package, OpenMx. This package is only available from it\'s own repository, but specifying this repository in
See: http://thecoatlessprofessor.com/programming/r-data-packages-in-external-data-repositories-using-the-additional_repositories-field/
Specifically, note that you can specify:
if (!requireNamespace("namepackage", quietly = TRUE)) {
install.packages("namepackage", repos = "http://location-of.com/repo")
}
To auto add the repo on package load, use:
.onLoad <- function(libname) {
repos = getOption("repos")
repos[""] = "http://location-of.com/repo"
options(repos = repos)
invisible(repos)
}
This negates the need to set repos = ...
in install.packages()
.