Created
February 11, 2019 18:31
-
-
Save McClellandLegge/647d7b78169269b6b213ea07f560055b to your computer and use it in GitHub Desktop.
Using Object in Shiny App that is defined in another code chunk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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