I am trying to fetch multiple values that are returning from selectinput textbox to the title of the chart but only able to include its first value.
UI
ui <- fluidPage(
headerPanel(title = "Shiny Tabs output Example"),
sidebarLayout(
sidebarPanel( width = 3,
selectInput("country_id", "Select your countries for cases (multiple selection allowed)",
choices = unique(covid_df$Country_Region), multiple = T, selected = c("US","Russia","India"))
),
mainPanel( width = 9,
tabsetPanel(type = "tab",
tabPanel("Bar Plot", plotOutput("plot_id")),
tabPanel("Box Plot", plotOutput("boxplot_id")
)
)
)
)
Server
server <- function(input, output) {
output$plot_id <- renderPlot({
gather_df %>%
filter(Country_Region %in% input$country_id) %>%
ggplot(aes(x = Case_Type, y = Cases_Count, fill = Case_Type)) + # fill = c("maroon","red","blue","orange")
geom_bar(stat = "identity") + #
facet_wrap(~Country_Region) +
theme_bw() +
theme(axis.text.y = element_text(size = 11))+
labs(title = paste("Bar Plot comparison with all cases type for Countries:", input$country_id))
})
}
# Run the application
shinyApp(ui = ui, server = server)
Problem
labs(title = paste("Bar Plot comparison with all cases type for Countries:", input$country_id))
Above statement is including only first country from the user inputs and not all the countries.
Tried
I have already tried below code but none is helping:
labs(title = paste("Bar Plot comparison with all cases type for Countries:", as.list(input$country_id)))
and
labs(title = paste("Bar Plot comparison with all cases type for Countries:", as.vector(input$country_id)))
and
labs(title = paste("Bar Plot comparison with all cases type for Countries:", pull(input$country_id)))
# last one throws an error.
I am new to R & Rshiny and getting confused when working with returns in Rshiny so unable to resolves these small issues.