Skip to content

Instantly share code, notes, and snippets.

@McClellandLegge
Created February 11, 2019 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McClellandLegge/647d7b78169269b6b213ea07f560055b to your computer and use it in GitHub Desktop.
Save McClellandLegge/647d7b78169269b6b213ea07f560055b to your computer and use it in GitHub Desktop.
Using Object in Shiny App that is defined in another code chunk
---
title: "Demo"
runtime: shiny
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
df <- head(WorldPhones, 5)
```
```{r eruptions}
shinyApp(
ui = fluidPage(
selectInput("region", "Region:",
choices = colnames(df)),
plotOutput("phonePlot")
),
server = function(input, output) {
output$phonePlot = renderPlot({
barplot(df[,input$region]*1000,
ylab = "Number of Telephones", xlab = "Year")
})
},
options = list(height = 500)
)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment