Create a report-section object that stores text and optional R code for a
section of a camReport report. Report sections can be
added to a report to make report generation more flexible, modular, and
extensible.
Arguments
- name
A character string giving a unique name for the report section.
- title
A character string giving the section title displayed in the report. The default is
"".- parent
A character string naming the parent section, or
NULL(default) for a top-level section.- txt
A character vector or list containing text to include in the report section. The default is
NULL.- code_setting
Optional R Markdown chunk options for the code chunk. For example,
{c(echo = FALSE, results = "asis")}. The default isNULL.- packages
An optional character vector giving packages required by the code chunk. The default is
NULL.- code
Optional R code supplied inside braces, for example,
{ plot(1:10) }.
Details
Each report section must have a unique name. If a new section with the same
name as an existing section is added to a report, the existing section is
replaced.
A report section can contain text only, code only, or both text and code.
When the code chunk needs access to the associated camReport object, the
object can be referred to as object inside the code block.
This function is useful for creating custom report modules or extending the default camtrapReport workflow with project-specific text, tables, figures, or analyses.
See also
camData(), report(), updateReportSection(), testSection()
Other report sections:
section_names(),
testSection,.textSection-method,
updateReportSection()
Examples
tx <- reportSection(
name = "introduction",
title = "Introduction",
parent = NULL,
txt = "This is an introduction section."
)
tx
#> class : .textSection
#> ===========================================================
#> name of the object : introduction
#> title : Introduction
#> parent :
#> is R code included? : FALSE
#> -----------------------------------------------------------
# Create a section containing text and an R code chunk
tx2 <- reportSection(
name = "methods",
title = "Methods",
parent = NULL,
txt = "This section summarises the camera deployment design.",
code_setting = {
c(echo = FALSE, results = "asis", warning = FALSE)
},
code = {
object$camera_setup |>
summary()
}
)
tx2
#> class : .textSection
#> ===========================================================
#> name of the object : methods
#> title : Methods
#> parent :
#> is R code included? : TRUE
#> -----------------------------------------------------------