extract_package_details.RdThe function automatically detects the current R script file
(works best in RStudio), parses the code to identify function calls,
determines which packages they belong to, and creates a summary of all
non-base R packages used in the script. It handles both namespace-qualified
function calls (e.g., dplyr::filter) and regular function calls, while
filtering out base R functions and control structures.
extract_package_details(ignore_comments = TRUE)A data frame with the following columns:
Character. Name of the package
Character. Comma-separated list of functions called from this package
Character. Version number of the installed package
Character. Formatted citation for the package
This function analyses the current file (an R script, Rmd or qmd file) to extract information about all functions called within the code, identifies their associated packages, and returns a summary of packages used with version and citation information.
Works best when run from RStudio with an active source file
Requires that referenced packages are already loaded/installed
Will not detect functions called through indirect methods (e.g., do.call())
if (FALSE) { # \dontrun{
# Run this function from within an R script to analyze its dependencies
package_info <- extract_package_details()
# Include functions from commented code
package_info_all <- extract_package_details(ignore_comments = FALSE)
print(package_info)
} # }