R Shiny App to select search area(s) and generate reproducible reports (R Markdown) in support of the project "Reproducible Reports for Species at Risk: Development of a tool to produce consistent reports on Species at Risk within Predicted Exposure Zones (PEZ) for a variety of threats and activities, focusing on Maritimes Region as a pilot".
Code is publicly available via this repository. However, due to issues related to Protected B information, the data are not publicly accessible. As a result, currently, only core members of our team at DFO can generate the reports in response to requests for information internal to DFO. The core team is not, and should not, be perceived as data providers or data custodians.
New report requests are being tracked since October 2022 in https://github.com/orgs/dfo-mar-odis/projects/2/views/26
This new way of requesting/tracking reports will support the process of creating requests to the team, not to individual folks. Furthermore, by using this tracking approach we can keep reporting a list of requests. This helps us justify spending our work time on its development.
To do a new request:
- Make sure you have a GitHub account (or join https://github.com/)
- Please confirm with RAP team whether you are in the list of members authorized to request reports (due to limited capacity, we are not able to support all requests)
- Access the repo main page: https://github.com/dfo-mar-odis/shinySpatialApp
- On the top left, select the tab 'Issues'
- On the top right, select green tab 'New Issue'
- Select 'RRRequests' and click 'Get Started'. This step will prompt you to add all the details of your requests.
- Please send an email to Jake Coates. He will support next steps.
install.packages("remotes")
remotes::install_deps()Adding a package:
usethis::use_package("packageName")After adding a new package, commit the updated description file to source control.
After making sure that you have the necessary permissions to access the data, run:
source(here::here("reports/R/dataFunctions.R"))
copy_rdata_files()shiny::runApp("app")-
config.Rcontains key configuration parameters, including the region, file paths, and the list of Open Data records checked by the github action; -
appincludes all the files needed to run the application; -
app/wwwincludes image (e.g. logos), the.cssfile, and report preview once generated; -
app/datacontains the local versions of all data used in running the application; -
app/Rincludes the R scripts used by the shiny app; -
app/templatesincludes the base.Rmdfiles for each report section, split by language; -
app/outputincludes all outputs once generated: selected geometries as a.geojsonand the report in all format (the different section are also added); -
app/modulesincludes RShiny module files; -
reportsincludes all the files needed to render the rmd reports; -
reports/dataprocessingcontains the common preprocessing scripts to prepare data for use in the application, as well as the scripts used in github actions; -
reports/sectionsincludes the rmarkdown and preprocessing script for each subsection of the report; -
reports/sections/templatecontains a simple template with basic functionality; -
reports/R/contains the R functions needed in the rmd to generate the reports; -
tests/testthatcontains the unit test scripts that are run when test_local() is called.
Here are suggestion of things to think about when .Rmd sections of the rpeort are not running:
- Open the .rmd hat is not working (e.g. sections/sarsearch/sarsearch.rmd) and ctrl+enter each chunk. Make sure you run and each line inside the if (FALSE) blocks at the top.
- No need to play with paths, everything should work, except the problematic line.
- NULL as an output is ok.
- once you find the error:
- Figure out what the error message means
- Think about why this showed up now
- Try to fix the error
If all this fails, feel free to reach out to Quentin.
-
Branch from main (e.g. from main create and checkout a new branch:
git checkout -b my_dev_branchor in RStudio) -
Do work in branch, e.g. addressing some issue.
-
Add and commit changes.
-
Routinely Push work to the remote version of
my_dev_branch:git push -u origin my_dev_branch -
Routinely Pull (i.e. git fetch + git merge) from origin/main to deal with any conflicts
git pull origin main. Optional: If someone else worked on the same branch as you, and had pushed a commit up, you could rungit pull origin my_dev_branchto sync with those updates. -
Once the original issue is fixed, ensure the report can still be generated through the app and that the test suite passes:
testthat::test_local() -
If everything still runs correctly, make a pull request from github website to merge
my_dev_branchintomain. -
Other developers will then respond to the request and test out the code in their dev branches to make sure there are no issues.
-
Once all lights are green, the pull request will be accepted and the new code merged into main branch.
Note: This is only relevant for DFO project developers that have access to the IN folder.
When metadata is updated in the preprocessing, you need to resave it before it will update in the rendered reports.
For this:
-
Step 1: Save Data Locally. Run the whole preprocessing script up to the save line. See this link for an example of a pre-processing file: https://github.com/dfo-mar-odis/shinySpatialApp/blob/main/reports/sections/rockweed/rockweed_preprocessing.R
-
Step 2: Render Report to make sure everything is working smoothly
-
Step 3: Save Data in the IN folder so all project collaborators can use the most up-to-date information.
remoteFileSavePathis a variable with the path to the data folder on the IN drive. To save data in the IN folder, replacelocalFileSavePathwithremoteFileSavePathinside the save function e.g. Replacesave(rockweed_rr, file = file.path(localFileSavePath, "Open/rockweed_rr.RData"))wtihsave(rockweed_rr, file = file.path(remoteFileSavePath, "Open/rockweed_rr.RData")) -
Step 4: Write a nice commit in yor branch to announce this update!
The following provides guidance on how to include titles and subtitles throughout the report to match the formatting. Main modules are presented, with dummy subtitles for data titles and search-area results.