Reads in an Rmd file or an R script and converts it to a list of TreeHarp objects.
rmd_to_forestharp(fname, verbose = FALSE)There are three possible return outcomes: (1) NA, indicating that
purl was unable to extract the R expressions from the
Rmd/qmd file. (2) A list with two components, named forest and
line_nums, each being NA. (3) A list with two components, named as in
(2), containing the TreeHarp objects and a vector of line numbers.
If there are syntax errors in the file, the expressions may not be parsed
correctly. The verbose option will reflect this.
The filename that is to be read in.
If TRUE, then messages will be printed to enable debugging. dropped.
If an Rmd or qmd file is supplied as input, it is first converted
to an R script before get_source_expressions is used
to try to parse the expressions. These expressions are then matched to the
original file to retrieve line numbers. Unlike previous versions of this
function, line numbers will always be returned.
Expressions that could not be parsed will be returned as NA.
Line numbers are extracted using get_source_expressions from
the lintr package.
fapply, extract_chunks,
extract_chunks, get_source_expressions