two_pager_indicator_table.Rmd
A table template is used to create the short-form ESP indicator
table. An example template is included in the AKesp R package in the
inst/two-pager_table_template.csv
file. This template can
be modified to create a custom table for your ESP update.
indicator | status_2024 | status_image | trend | category | type |
---|---|---|---|---|---|
test | test | red_up.png | test_time_series2.png | predictive | Ecosystem |
test | test | blue_down.png | test_time_series2.png | contextual | Ecosystem |
test | test | grey_nochange.png | test_time_series2.png | fishery performance | Socioeconomic |
test | test | grey_up.png | test_time_series2.png | economic | Socioeconomic |
test | test | grey_down.png | test_time_series2.png | community | Socioeconomic |
Out of the six columns in the template, only two will propagate
directly to the final output. The other four are used for internal
purposes. indicator
and status_2024
will
transfer to the final output as written. status_image
should include the file path to the status icon that should be displayed
for each indicator. trend
should include the file path to
an image that will be used in the table. Image file paths should include
only the file name, and no directory or full path information, which
will be added later. category
should be one of
‘predictive’, ‘contextual’, ‘fishery performance’, ‘economic’, or
‘community’, and will be used to color the table cells.
type
should be one of ‘Ecosystem’ or ‘Socioeconomic’ and
will be used to subset the table output.
The table is created with the create_table_indicator
function. All 3 parameters are required. data
should be a
file path to the template spreadsheet. dir
should be the
directory where the status icons and trend images are stored.
type
should be either ‘Ecosystem’ or ‘Socioeconomic’, and
will be used to subset the table output.
AKesp::create_indicator_table(data = read.csv(here::here("inst/two-pager_table_template.csv")),
dir = here::here("inst/images"),
type = "Ecosystem")
#> Joining with `by = join_by(category)`
Indicator |
2024 Status |
Trend |
---|---|---|
test |
test |
|
test |
test |
AKesp::create_indicator_table(data = read.csv(here::here("inst/two-pager_table_template.csv")),
dir = here::here("inst/images"),
type = "Socioeconomic")
#> Joining with `by = join_by(category)`
Indicator |
2024 Status |
Trend |
---|---|---|
test |
test |
|
test |
test |
|
test |
test |
The create_indicator_table
function returns a
flextable
object, which can be saved as an image with the
flextable::save_as_image
function. Make sure that all
dependencies are installed, including magick
.
img <- AKesp::create_indicator_table(data = read.csv(here::here("inst/two-pager_table_template.csv")),
dir = here::here("inst/images"),
type = "Ecosystem")
flextable::save_as_image(img,
path = here::here("data-raw/indicator_table_eco.png"))