[R-pkg-devel] Question regarding listing base and recommended packages programmatically and efficiently

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Thu Oct 12 17:50:30 CEST 2023


On Thu, 12 Oct 2023 11:32:24 -0400
Mikael Jagan <jaganmn2 using gmail.com> wrote:

>      > mk <- file.path(R.home("share"), "make", "vars.mk")
>      > pp <- sub("^.*= +", "", grep("^R_PKGS_RECOMMENDED",
>      > readLines(mk), value = TRUE))
>      > sort(strsplit(pp, " ")[[1L]])  
>       [1] "KernSmooth" "MASS"       "Matrix"     "boot"       "class"
>       [6] "cluster"    "codetools"  "foreign"    "lattice"    "mgcv"
>      [11] "nlme"       "nnet"       "rpart"      "spatial" "survival"
> 
> I grepped around and did not find variables in any base namespace
> containing the names of these packages.  It wouldn't be too hard to
> define such variables when R is configured/built, but maybe there are
> "reasons" to not do that ... ?

tools:::.get_standard_package_names does that at package installation
time, but it's still not public API.

A call to installed.packages() may take a long while because it has to
list files in every library (some of which can be large and/or
network-mounted) and parse each Meta/package.rds file, but at least
list.files() is faster than that.

If I had to make a choice at this point, I would hard-code the list of
packages, but a better option may surface once we know what Tony needs
the package lists for.

-- 
Best regards,
Ivan




More information about the R-package-devel mailing list