library(shiny)
a <- data.frame(a)
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("Ideology",
"Ideology (1- Very Liberal ; 5- Very Conservative:)",
min = 1,
max = 5,
value = 3)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
server <- function(input, output) {
output$distPlot <- renderPlot({
# Aqui esta o truque: Utilize o comando filter para fazer com que o input$Ideology torne o gráfico dinâmico
ggplot(filter(a, ideo5==input$Ideology), aes(x=pid7)) + geom_histogram(binwidth = 0.25) + xlab("7 Point Party")
})
}
shinyApp(ui = ui, server = server)