Skip to content
Prev 61115 / 63421 Next

tools:: extracting pkg dependencies from DCF

Hi Jan and Jan,

Can you explain a little more what exactly you want the non-recursive,
non-version aware dependencies from an individual package for?

Either way package_dependencies will do this for you* with a little
"aggressive convincing". It wants output from available.packages, but who
really cares what it wants? It's a function and we are people :)
"Suggests", "Imports", "LinkingTo"), colnames(db)))
$rtables
 [1] "methods"    "magrittr"   "formatters" "dplyr"      "tibble"
 [6] "tidyr"      "testthat"   "xml2"       "knitr"      "rmarkdown"
[11] "flextable"  "officer"    "stats"      "htmltools"  "grid"


The only gotcha that I see immediately is that "LinkingTo" isn't always
there (whereas it is with real output from available.packages). If you know
your package doesn't have that (or that it does) at call time , this
becomes a one-liner:

package_dependencies("rtables", db =
read.dcf("~/gabe/checkedout/rtables_clean/DESCRIPTION"), which =
c("Depends", "Suggests", "Imports"))
$rtables
 [1] "methods"    "magrittr"   "formatters" "dplyr"      "tibble"
 [6] "tidyr"      "testthat"   "xml2"       "knitr"      "rmarkdown"
[11] "flextable"  "officer"    "stats"      "htmltools"  "grid"

You can also trick it a slightly different way by giving it what it
actually wants
"PACKAGES"))
[1] TRUE
$rtables
[1] "methods"    "magrittr"   "formatters" "stats"      "htmltools"
[6] "grid"
$rtables
 [1] "methods"    "magrittr"   "formatters" "stats"      "htmltools"
 [6] "grid"       "dplyr"      "tibble"     "tidyr"      "testthat"
[11] "xml2"       "knitr"      "rmarkdown"  "flextable"  "officer"

So the only real benefits I see that we'd be picking up here is automatic
filtering by priority, and automatic extraction of the package name from
the DESCRIPTION file. I'm not sure either of those warrant a new exported
function that R-core has to maintain forever.

Best,
~G

* I haven't tested this across all OSes, but I dont' know of any reason it
wouldn't work generally.
On Fri, Oct 14, 2022 at 2:33 PM Jan Gorecki <j.gorecki at wit.edu.pl> wrote: