I am looking for a slick way to programmatically get the Imports:
and Depends:
packages of a package. The trick is that the method should work regardless of whether the package is
devtools::load_all()
, orDesired functionality:
package_deps("dplyr")
## [1] "assertthat" "bindrcpp" "glue" "magrittr" "methods" "pkgconfig"
## [7] "rlang" "R6" "Rcpp" "tibble" "utils"
Notice that the version numbers are all stripped away.
I am writing this post because it seems like this should already exist. (After all, install.packages()
needs similar functionality.) I would rather not have to manage all the special cases myself.
The pacman package that I maintain does this:
if (!require("pacman")) install.packages("pacman")
pacman::p_depends(dplyr)
$Imports
[1] "assertthat" "bindrcpp" "glue" "magrittr" "methods"
[6] "pkgconfig" "rlang" "R6" "Rcpp" "tibble"
[11] "utils"
$LinkingTo
[1] "Rcpp" "BH" "bindrcpp" "plogr"
$Suggests
[1] "bit64" "covr" "dbplyr" "dtplyr"
[5] "DBI" "ggplot2" "hms" "knitr"
[9] "Lahman" "mgcv" "microbenchmark" "nycflights13"
[13] "rmarkdown" "RMySQL" "RPostgreSQL" "RSQLite"
[17] "testthat" "withr"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With