Code Monkey home page Code Monkey logo

shinywqg's Introduction

shinywqg

img R-CMD-check Codecov test coverage Apache license

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.

  1. 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

  1. 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.

shinywqg's People

Contributors

sebdalgarno avatar aylapear avatar joethorley avatar atillmanns avatar repo-mountie[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.