View source: R/extract_functions.R
extract_functions | R Documentation |
This function finds all of the R functions in a character vector of R code.
For R scripts, first use readLines()
or readr::read_file()
to import
the script into a character vector. For R Markdown or Quarto documents,
first use extract_code()
to find all of the R code in code blocks. The
character vector can then be passed to extract_functions()
to find all of
the functions. By default, all instances of functions are returned. To omit
duplicate functions, set duplicates = FALSE
.
extract_functions(code, duplicates = TRUE)
code |
Object that contains R code. |
duplicates |
Logical indicating whether to include duplicates of functions or whether to remove duplicates (default is TRUE, which includes duplicates). |
Returns character vector of function names without parentheses (e.g., it returns "library" rather than "library()") included in R code.
This function is adapted from one Yihui Xie posted at https://yihui.org/en/2023/01/func-call/.
Other functions for extracting code and functions:
build_functions_df()
,
extract_code()
extract_functions(extract_code(
"https://raw.githubusercontent.com/JeffreyRStevens/flashr/refs/heads/main/README.Rmd"
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.