February 03 2021

The Shiny Package

Shiny is an R package which combines R programming with the interactivity of the web.

install.packages("shiny")

Methods for Use

  • Online
  • Locally

Online

Easiest Method

Locally

No Internet required once configured

  • Install R and RStudio (done)
  • Install Required packages (app dependent)
  • Download, open in RStudio and click “Run App”

Web App Demonstration

Online:

Local:

Troubleshooting Errors

  1. Reload the app and try again. (refresh browser, or click stop, and run app again in RStudio) When the app throws an error, it stops. All other tabs/reports will no longer function until the app is reloaded.
  2. Read the getting started section on the home page. This is a quick summary of tips to avoid issues, and will be updated as needed.
  3. Check to see if SDA and NASIS Web Reports are operational, if they aren’t working, then the app won’t work either.
  4. Double check your query inputs. (typos, wildcards, null data, and too much data, can be common issues)
  5. 5 minutes of inactivity will cause the connection to drop, be sure you are actively using the app.
  6. Run the app locally - the online app does not show console activity, which can be a big help when identifying problems.
  7. Check the app issues page to see if the issue you are experiencing is already documented. (Polite but not required)
  8. Contact the app author (john.hammerly@usda.gov)

Shiny App Embedding

Shiny App Code

shinyApp(
  
  ui = fluidPage(
    selectInput("region", "Region:", 
                choices = colnames(WorldPhones)),
    plotOutput("phonePlot")
  ),
  
  server = function(input, output) {
    output$phonePlot <- renderPlot({
      barplot(WorldPhones[,input$region]*1000, 
              ylab = "Number of Telephones", xlab = "Year")
    })
  }
)

Questions

Kahoot Quiz

  1. What new features in RStudio are available for you to use once the shiny package is installed?

  2. The Region 11 Web App uses which 2 data sources for its reports?

  3. If an error occurs while using the Region 11 Web App, what should you do?

  4. A shiny app consists of:

References