Learn R Programming

autoharp (version 0.2.0)

rmd_to_forestharp: Convert to TreeHarp objects

Description

Reads in an Rmd file or an R script and converts it to a list of TreeHarp objects.

Usage

rmd_to_forestharp(fname, verbose = FALSE)

Value

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.

Arguments

fname

The filename that is to be read in.

verbose

If TRUE, then messages will be printed to enable debugging. dropped.

Details

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.

See Also

fapply, extract_chunks, extract_chunks, get_source_expressions