View source: R/extract_functions.R
extract_code | R Documentation |
To extract code blocks, apply extract_code()
to R Markdown or Quarto files
either locally or via a URL. This function returns a character vector where
each line of content from an R code block is an element of the vector. Code
block options are not returned—only the content of the block. Code blocks
from other languages/engines (e.g., Python) are not returned.
extract_code(file, empty = TRUE, comments = TRUE)
file |
Character string of file name for text that includes code blocks. Can be local file or URL. |
empty |
Logical indicating whether to include empty lines ( |
comments |
Logical indicating whether to include comment lines starting
with |
Returns character vector of individual lines of 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_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.