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

2023-10-14 Thread Martin Maechler
> Henrik Bengtsson > on Sat, 14 Oct 2023 10:37:14 -0700 writes: > On Sat, Oct 14, 2023 at 5:25 AM Martin Maechler > wrote: >> >> > Ivan Krylov >> > on Thu, 12 Oct 2023 18:50:30 +0300 writes: >> >> > On Thu, 12 Oct 2023 11:32:24 -0400 >>

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

2023-10-14 Thread Henrik Bengtsson
On Sat, Oct 14, 2023 at 5:25 AM Martin Maechler wrote: > > > Ivan Krylov > > on Thu, 12 Oct 2023 18:50:30 +0300 writes: > > > On Thu, 12 Oct 2023 11:32:24 -0400 > > Mikael Jagan wrote: > > >> > mk <- file.path(R.home("share"), "make", "vars.mk") > >> > pp <- sub("^.*=

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

2023-10-14 Thread Martin Maechler
> Ivan Krylov > on Thu, 12 Oct 2023 18:50:30 +0300 writes: > On Thu, 12 Oct 2023 11:32:24 -0400 > Mikael Jagan wrote: >> > mk <- file.path(R.home("share"), "make", "vars.mk") >> > pp <- sub("^.*= +", "", grep("^R_PKGS_RECOMMENDED", >> > readLines(mk), value =

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

2023-10-12 Thread Ivan Krylov
On Thu, 12 Oct 2023 11:32:24 -0400 Mikael Jagan 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"

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

2023-10-12 Thread Mikael Jagan
Maybe something like this: > isRecommendedPkg <- utils:::isBasePkg > body(isRecommendedPkg)[[c(3L, 3L)]] <- "recommended" > installed <- unique(list.files(.libPaths())) > installed[vapply(installed, isRecommendedPkg, NA)] [1] "KernSmooth" "MASS" "Matrix" "boot"

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

2023-10-12 Thread Duncan Murdoch
It would be much faster (but slightly less reliable) to use list.files(.libPaths()) to get the names of all installed packages, and then filter them to the known list of base and recommended packages, which changes very rarely. Duncan Murdoch On 12/10/2023 8:34 a.m., Tony Wilkes wrote: Dear

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

2023-10-12 Thread Thierry Onkelinx
Dear Tony, Much will depend on what information you need from the output of installed.packages()? Best regards, ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team

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

2023-10-12 Thread Tony Wilkes
Dear all, In my R package that I'm developing, I use `installed.packages(priority = "base")` to programmatically get all core/base R packages (i.e. base, stats, etc.). And similarly, I use installed.packages(priority = "recommended")​` to programmatically get the recommended R packages (i.e.