Skip to content

Code for riskmapr apps for invasive weed risk mapping

License

Notifications You must be signed in to change notification settings

apear9/riskmapr

Repository files navigation

DOI

The riskmapr shiny apps

This website/GitHub repository is for the suite of riskmapr shiny apps. In this document, we outline how to download and run them.

The underlying methodology is outlined in Froese, Pearse and Hamilton (2019).

Contents of the repository

The GitHub repository apear9/riskmapr contains three .R files corresponding to the three riskmapr Shiny apps:

  • shiny_app_geoprocessing.R, which lets users perform a range of customized geoprocessing functions to prepare spatial data for use in the app shiny_app_susceptibility, and download the outputs.
  • shiny_app_suitability.R, which lets users run a spatially explicit model of suitability for weed invasion, and download the generated risk maps.
  • shiny_app_susceptibility.R, which lets users run a spatially explicit model of susceptibility to weed invasion, and download the generated risk maps.

The folder sensitivity_analysis contains the scripts required to perform a sensitivity analysis on our model, with a focus on the resolution of the underlying spatial data, the uncertainties chosen for the child nodes of the network, and the numerical values assigned to the discrete risk factor states. Further instructions are provided in a readme file in that folder.

There are two additional scripts which can be run to ensure the R packages required for the apps are installed:

  • installing_packages_for_geoprocessing.R (for shiny_app_geoprocessing.R)
  • installing_packages_for_suitability_susceptibility.R (for shiny_app_suitability.R and shiny_app_susceptibility.R)

The other files in the repository exist for the purposes of licensing this software under GPL v3.0 and supporting the website that holds this documentation. These are not used to run the riskmapr apps.

Deploying and running the shiny apps locally

The process for running these Shiny apps is easy if you are using RStudio. Simply:

  • Download the code for the apps. Please make sure the R scripts have been saved in a new folder.

download

  • Install the requisite packages using the installing_packages scripts.
  • Open the .R file for the app you want to run.
  • Go to the 'Run App' button in the top-right of the script window.
    • Click on the small black arrow next to the button.
    • Click 'Run External' from the small drop-down menu that appears. This will allow the app to run in an internet browser, which in turn will allow the outputs to be downloaded without fuss.

runexternalfurtherinstructions

  • Click 'Run App'.

shiny_app_run_instructions

Deploying the shiny apps online to your own shinyapps.io account

There may be situations where it is desirable to share the app with collaborators without forcing them to interact with the code or the R language. In this case, one option is to deploy the app to shinyapps.io (or some other R Shiny server). An account with shinyapps.io with space for 5 apps is free, so we provide instructions for deploying the app to this service. Go to the website and sign up following the instructions on the page.

Once the shinyapps.io account has been created, simply:

  • Make sure all required packages have been installed on your machine.
  • Open the R script for the desired app in RStudio and click the blue publishing icon in the top right-hand corner of the scripting window.

publishapp

  • Click through the next few windows asking you to choose a publishing service. Choose shinyapps.io when asked which one to use.

  • You will be asked to link your shinyapps.io account to your computer so that the app can be published through RStudio.
  • You will see this screen. From here, go to an internet browser and log into shinyapps.io using your account details.

  • Find the menu for the access tokens. The directions are indicated below.

  • You will find a table with entries that look like this. Select your access token and click on the 'Show' button. You will then be taken to a pop-up window where you can click a button reading 'Show Secret'. Click on it.

revealaccesstoken

  • Copy and paste the codechunk starting with rsconnect:: into this window which you should have open in RStudio.
  • Click 'Connect Account'.
  • Now the publishing menu should be open.

  • Before proceeding any further, check that the app is being uploaded to the right account.
  • Then, firstly, click the button 'Uncheck All' (indicated as 1. in the figure above).
  • Secondly, rename the app to something of your choosing (in the box indicated as 2. in the figure above).
  • Thirdly, click the Publish button (3. in the figure above).
  • R may prompt you to install packages. Do this if required.
  • A new window should open detailing the progress of RStudio in deploying the app to your shinyapps.io account. An internet browser window will open once this is complete, and you will be able to use the app online. The URL can be shared with anyone.

References

Froese, J., Pearse, A.R., and Hamilton, G. (2019). Rapid spatial risk modelling for management of early weed invasions: balancing ecological complexity and operational needs. Methods in Ecology and Evolution. doi: 10.1111/2041‐210X.13284