Customize to_rmd
The methods for this S3 generic can be extended by the app developer or even overwritten.
For this a function with the name to_rmd.<class> should be defined in the
Global Environment or registered as an S3 method, where <class> is the class of the
object to be converted.
For example, to override the default behavior for code_chunk class, you can use:
to_rmd.code_chunk <- function(block, ...) {
# custom implementation
sprintf("### A custom code chunk\n\n```{r}\n%s\n```\n", block)
}
Alternatively, the S3 method can be registered using registerS3method("to_rmd", "<class>", fun)
Defaults
teal.reporter provides default to_rmd methods for several common classes that
returns the content in appropriate R Markdown syntax.
These include:
character
code_chunk() objects
ggplot2 plots
data.frame
flextable
rtables tables
and others.
All of these defaults can be overridden by defining new to_rmd.<class> methods.
These methods are implemented internally using the helper function .to_rmd.<class>.