R package dependencies not installed from Additional_repositories

后端 未结 3 573
栀梦
栀梦 2020-12-19 15:42

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

3条回答
  •  旧时难觅i
    2020-12-19 16:11

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

提交回复
热议问题