Reporting Workflows
Parameterized Caption
Reused Text
Parameterized reporting keeps the same template while changing the values inserted into it.
Program
Play the script to choose a region and see the caption update from the same template.
parameterized_caption.R
regions <- c("north", "south", "west")
region_index <-
count <- c(12, 9, 15)[region_index]
region <- regions[region_index]
caption <- paste("Region", region, "has", count, "records")
cat(caption, "\n", sep = "")
regions <- c("north", "south", "west")
region_index <-
count <- c(12, 9, 15)[region_index]
region <- regions[region_index]
caption <- paste("Region", region, "has", count, "records")
cat(caption, "\n", sep = "")
regions <- c("north", "south", "west")
region_index <-
count <- c(12, 9, 15)[region_index]
region <- regions[region_index]
caption <- paste("Region", region, "has", count, "records")
cat(caption, "\n", sep = "")
parameter
`region_index` is a small parameter that controls the report value.
lookup
`regions[region_index]` maps the parameter to display text.
template
`paste` fills the same caption shape with selected values.