shinywqg
shinywqg is a Shiny application to run the ’B.C. Ambient Water Quality Guidelines. Guidelines are determined based on information from the BC Data Catalogue.
The shiny application is also available at https://bcgov-env.shinyapps.io/bc_wqg/.
Usage
Installation
To install the developmental version from GitHub
# install.packages("remotes")
remotes::install_github("bcgov/shinywqg")
Demonstration
# install.packages("shinywqg")
shinywqg::run_wqg_app()
Internal Info
How to Test Changes to Water Quality Guidelines Data
When you make changes to the water guidelines you can check that they
don’t break the app before you upload the new version to the BC Data
Catalogue. To do this make minor modifications in the R/mod_data.R
script to read in the new data. Then run the app locally to ensure it is
working before deploying. You will need to add the new data to the root
folder.
mod_data_server <- function(input, output, session) {
ns <- session$ns
observe({
### comment out these lines
# file_name <- "85d3990a-ec0a-4436-8ebd-150de3ba0747"
# limits <- get_data(file_name)
### add this line
limits <- readr::read_csv("all_wqgs-2.csv")
})}
To Test Changes to the App
Make the required changes to the scripts in the R
folder (like
described above). Then open the app.R
script which is located in the
root folder and run. This should launch the app with your changes
implemented.
How to Update the Internal Backups
Once a new version of the guidelines have been added to the BC Data Catalogue you will need to update the internal backup data.
- Open
data-raw/internal.R
- Run the script from the top to bottom
- Deploy the app
How to Add New Lookup Tables
Obtain the unique ID for downloading the data from the BC Data Catalogue once it has been added to the BC Data Catalogue. Add this ID to the Limit column of the Water Quality Guidelines. The app should automatically add a lookup function for that chemical/use/media.
You will need to manually add it to the internal backup data. Open
data-raw/internal.R
add one line assigning the ID to a variable and
then add that variable to the lookup hash vector.
# example
hash_ni_chronic <- "85d3990a-ec0a-4436-8ebd-150de3ba0747"
# update this line with the new hash name
lookup_hash <- c(hash_cu_chronic, hash_cu_acute, hash_ni_chronic)
How to Find Unique Hash/ID for an Item on the BC Data Catalogue
There is more then one way to find the unique hash. Here are few ways.
- Look at the url of the item in the BC Data Catalogue website. The
random coding at the end of the url is the unique hash needed. For
the example below the unique hash is
85d3990a-ec0a-4436-8ebd-150de3ba0747
Example: “https://catalogue.data.gov.bc.ca/dataset/85d3990a-ec0a-4436-8ebd-150de3ba0747”
- Using the
bcdata
R package
library(bcdata)
# this list all the potential items
bcdc_list()
# find the name of the file and put it in the `bcdc_browse` function
bcdc_search("water-quality-guidelines-of-b-c-")
# read the output to get the ID for the record
Deployment
Run the deploy.R script. To check that everything is fully working run the test version first and then the public one. Then push the rsconnect to GitHub.
Contribution
Please report any issues.
Pull requests are always welcome.
Please note that this project is released with a Contributor Code of Conduct. By contributing, you agree to abide by its terms.