Hello,
I'm new to shiny. I have been able to create an app but I need it to create multiple charts corresponding to choices in 'Indicator name' of the UI and have the charts appear in order of selection. At the moment it only creates one chart and puts all the data in that creating a mess. Could you help? Thanks
The following creates the data (which works fine) and the app code is below that:
library(ggplot2)
library(fingertipsR)
library(tidyverse)
library(shiny)
ind <- c(90244, 90245)
df <- fingertips_data(IndicatorID = ind, AreaTypeID = 402)
df <- subset(df, df$AreaCode %in% c("E09000006", "E12000007", "E92000001"))
df$AreaName <- factor(df$AreaName, levels = c("Bromley", "London region", "England"))
df <- df[,c(2,6,12:13)]
Created on 2022-03-24 by the reprex package (v2.0.1)
ui <- fluidPage(selectInput(inputId = "ind", label = "Indicator name", choices = unique(df$IndicatorName), multiple = T), plotOutput("plot"))
server <- function(input, output, session) {
output$plot <- renderPlot({
df %>%
filter(IndicatorName == input$ind) %>%
ggplot(aes(x=Timeperiod, y=Value, colour = AreaName, group = AreaName)) +
geom_line() +
geom_point()
})
}
shinyApp(ui = ui, server = server)
Created on 2022-03-24 by the reprex package (v2.0.1)