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/.
To install the developmental version from GitHub
# install.packages("remotes")
remotes::install_github("bcgov/shinywqg")
shinywqg::run_wqg_app()
To update the app and data, the process is as follows:
- Test the app against updated data locally
- Upload the new data to the BC Data Catalogue
- Update the internal backup data in the app
- Deploy the updated app
First, ensure you have an up-to-date local copy of the repository, by pulling from GitHub (make sure you are on the master branch).
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. You will need to add the new data to the
inst/app
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")
})}
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 click “run” in the toolbar. Or, in the console run:
pkgload::load_all(".")
shinywqg::run_wqg_app()
This should launch the app with your changes implemented.
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
Open the scripts/deploy.R
file. To check that everything is fully
working run the test version first. If all looks good, run the public
one. Then commit and push the updated
rsconnect/shinyapps.io/bcgov-env/BC_WQG.dcf
file to GitHub.
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)
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
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.