Parses an R or R Markdown file for the package names that would be required to run the code.
file to parse for required package names
This function uses regular expressions to search through a file
containing R code to find required package names. It extracts not only
package names denoted by
require, but also
packages not attached to the global namespace, but are still called with
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
a vector of package names as character strings
1 2 3 4 5 6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.