Get the names of available report sections or update which sections are
included in a camReport report.
Arguments
- keep
An optional character vector of section names to keep. When omitted, all available sections are returned.
- exclude
An optional character vector of section names to exclude. The default is
NULL.- x
- n
An optional character vector giving the names of report sections to include. When omitted, the current section names are returned.
Value
section_names() returns a character vector of section names.
sections() returns a character vector when n is omitted; otherwise, it
updates the supplied camReport object and returns it invisibly.
Details
section_names() returns the names of available report sections. It can be
used to identify valid section names before selecting sections with
sections().
sections() updates the report-section selection stored in a camReport
object. Only the selected sections are included when the report is generated.
When n is omitted, it returns the names of the object's currently available
sections without changing the object.
Examples
# List all available report-section names
available_sections <- section_names()
head(available_sections)
#> [1] "introduction" "methods" "study_area" "sampling" "location"
#> [6] "effort"
# \donttest{
# Load the packaged example dataset
source_dataset <- system.file(
"external",
"dataset",
package = "camtrapReport"
)
example_dataset <- tempfile("camtrapReport-example-")
dir.create(example_dataset)
invisible(file.copy(
list.files(source_dataset, full.names = TRUE),
example_dataset,
recursive = TRUE
))
cm <- camData(example_dataset)
#> The camReport object is being created...
#> Dataset size: 6.6 MB.
#> File size looks modest, but full object creation may still take several minutes depending on the number of records.
#> Setup is done!
#> Data loaded successfully in 27 sec.
#> camReport object is ready for GMU8 LEUVEN.
# Inspect the sections currently available for this object
current_sections <- sections(cm)
head(current_sections)
#> [1] "introduction" "methods" "study_area" "sampling" "location"
#> [6] "effort"
# Select a small subset of available sections
selected_sections <- head(current_sections, 4)
cm <- sections(cm, selected_sections)
#>
#> The report sections are updated.
# Show the selected section names
selected_sections
#> [1] "introduction" "methods" "study_area" "sampling"
unlink(example_dataset, recursive = TRUE, force = TRUE)
# }