View source: R/get_elements_by_type.R
get_elements_by_type | R Documentation |
Extract Sections of Same "Type" from Parse Tree
get_elements_by_type(x, result = NULL, dbg = TRUE)
x |
parse tree as returned by |
result |
optional. Result as returned by |
dbg |
if |
# Parse an R script file (here, a file from kwb.utils)
x <- parse("https://raw.githubusercontent.com/KWB-R/kwb.utils/master/R/log.R")
# For each "type" of code segment, extract all occurrences
elements <- get_elements_by_type(x)
# Show all for-loops
elements$`language|call|for|4|`
# Show all if-statements
elements$`language|call|if|3|`
# Show all if-else-statements
elements$`language|call|if|4|`
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.