Parse R code for required packages
Parses an R or R Markdown file for the package names that would be required to run the code.
parse_packages(fl)
fl |
file to parse for required package names |
Because it relies on regular expressions, it assumes all packages adhere to
the valid CRAN package name rules (contain only ASCII letters, numbers, and
dot; have at least two characters and start with a letter and not end it a
dot). Code is also tidying internally, making the code more predictable and
easier to parse (removes comments, adds whitespace around operators, etc).
R Markdown files are also supported by extracting only R code using
purl
.
a vector of package names as character strings
## Not run: cat('library(ggplot2)\n # library(curl)\n require(leaflet)\n CB::date_print()\n',file='temp.R') parse_packages('temp.R') unlink('temp.R') ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.