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
- installed or just loaded with
devtools::load_all(), or - attached or just available through the namespace.
Desired 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.