Render a .textSection object as a temporary HTML report to check whether
the section text and code can be rendered successfully.
Arguments
- x
A
.textSectionobject, usually created withreportSection().- object
An optional
camReportobject created bycamData(). The default isNULL.- view
A logical value (default
TRUE) specifying whether the rendered temporary HTML file is opened after rendering.
Details
Security: Testing executes the section's text interpolation and R code with your R process's permissions. Test only sections from sources you trust; this is not a sandbox or a security check. See modules.
This function is mainly used to test custom report sections before they are
added to a full camReport report. It checks whether
the
section text, R Markdown chunk settings, required packages, and R code can be
rendered successfully.
Declared module packages are checked for availability without being attached
to the R search path. Use explicit calls such as dplyr::filter() in custom
module code instead of relying on the previously automatic attachment of
declared packages. This requirement also applies when rendering full reports.
The object argument is only needed when the R code in the section refers to
a camReport object.
See also
camData(), reportSection(), updateReportSection(), report()
Other report sections:
reportSection,character-method,
section_names(),
updateReportSection()
Examples
tx <- reportSection(
name = "introduction",
title = "Introduction",
parent = NULL,
txt = "This is an introduction section.",
code = {
plot(1:10)
}
)
# Render the section without opening a browser
test_file <- testSection(
tx,
view = FALSE
)
file.exists(test_file)
#> [1] TRUE
# Remove the generated HTML file
unlink(test_file)
