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

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Thu Oct 12 14:46:36 CEST 2023


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 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. mgcv, lattice, etc.).
> 
> However, CRAN has requested to not use `installed.packages()`, as it is slow. I fully get and agree with that assesment. I used installed.packages()​` anyway because I could not find a better, fool-proof alternative.
> 
> Nonetheless, I was asked to change this code for optimalisation. So I would like to ask: how do I programmatically get all base/core R packages safely and efficiently, but without using `installed.packages()`? And the same question for recommended R packages. I have of course Googled it, and looked at R's documentation (though R's documentation is large, so it's easy to miss something); no solution found. So if any of you has a smart idea: I'm all ears.
> 
> Thank you in advance.
> 
> Kind regards,
> 
> Tony.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel




More information about the R-package-devel mailing list