| extract_package_details | R Documentation |
The 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)
ignore_comments |
Logical. If TRUE (default), ignores function calls within commented code (both R comments starting with # and HTML/XML comments ). If FALSE, extracts functions from all code including commented sections. |
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.
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
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())
getAnywhere,
packageVersion, citation
## Not run:
# 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)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.