This is an example shiny dashboard used for monitoring Ocean Use Survey results from SeaSketch. The data contained in this repo were entirely fabricated for demonstration purposes.
This app is designed to be both a functional example and a template that can be adapted to monitor other, real SeaSketch surveys. The goal was to generalize as much of the code as possible, allowing users to make minimal changes to apply it to their unique survey. That being said, surveys in SeaSketch can vary widely, and the amount of work required to adapt it to a given survey will also vary.
These are the basic steps required to adapt this framework to your survey
data/responses.csv
and data/shapes.json
with the respective survey exports from your SeaSketch project
shapes.json
data/eez.fgb
with a flatgeobuf containing the EEZ or other study area polygon applicable to your projectdata/survey_targets.csv
with your own targets CSV containing the columns "sector" and "target"R/project_variables.R
- this script contains all project-specific variables:
project
is the prefix added to all downloads from the appapp_title
will be diplayed in the upper left hand corner of the app uiseasketch_url
should be the link to your seasketch project page and is accessible via the "Responses Updated:" box on the "Overview" tabsectors
is a character vector of ocean use sectors in your projectregion
is the export id of your region questionregion_list
is a character vector of the regions respondents can chooseage_groups
is a character vector of the age groups respondents can choose fromgenders
is a character vector of the genders respondents can choose fromjson_columns
is a dataframe containing the export ids of any group response questions (which export as JSON-formatted strings), and their respective answer option objects (age_groups
and genders
in this example) - this excludes region
because it is parsed differently from the other group response questionscolumns_to_remove
is a character vector of any columns you don't need in your cleaned datashape_attributes_to_keep
is a character vector of shape attributes you want to keep in your cleaned spatial dataR/data_init.R
- this will process the data in responses.csv
and shapes.json
, writing five *.RDS
files to data/temp
:
respondent_info.RDS
contains aggregated response data, with one row per survey response (similar to how it's exported from SeaSketch)responses.RDS
contains response data with one row per sector responseshapes.RDS
contains the spatial data joined with other response data in the form of an SF
dataframedata_date.RDS
contains the date that responses.csv
was createdtemp_data_date.RDS
contains the date that the files in data/temp
were created (i.e. when R/data_init.R
was run)auth/create_user_db.R
create_user_db({initial_user}, {password}, {passphrase})
with the arguments:
initial_user
: your desired username to access the apppassword
: your desired passwordpassphrase
your desired passphrase to decrypt the databaseauth/users.sqlite
auth/passphrase.txt
which is read in global.R
- consider whether this is secure enough for your needscreate_user_db()
to login and any additional users can be added from the shinymanager admin interface accessible via the plus icon in the lower righthand corner of the appR/secure_option.R
which should assign TRUE
to the variable secure
- this is intended to be an easy gitignored way to develop locally with secure
set to FALSE
. Just make sure it's set to TRUE
wherever it's deployed. If you don't need your app secured, just set secure
to FALSE
and call it a dayCurrently, SeaSketch doesn't have a developer API for requesting survey data. Updates will need to be done by manually adding the latest responses.csv
and shapes.json
files exported from SeaSketch to the shiny app repo.