why single selection is working fine while multiple selection throwing error in shiny widget drop down reactive list. Could anyone plase tell me why it is happening and keeps throwing error for multiple selection.
library(shiny)
library(plotly)
library(dplyr)
library(xts)
library(lubridate)
library(shinycssloaders)
library(shinycustomloader)
library(htmltools)
library(htmlwidgets)
library(shinyWidgets)
# re<-read.csv("c:/users/dell/desktop/ssss.csv")
re<-tibble::tribble(
~Order.ID, ~Order_Date, ~CustomerName, ~State, ~City, ~sales,
"B-26180", "4/5/2017", "Bhaggyasree", "Andhra Pradesh", "Udaipur", 880L,
"B-26248", "4/6/2017", "Mohit", "Bihar", "Udaipur", 121L,
"B-26262", "4/7/2017", "Vaibhavi", "Himachal Pradesh", "Udaipur", 24L,
"B-26280", "4/8/2017", "Akshay", "Himachal Pradesh", "Udaipur", 145L,
"B-26162", "4/8/2017", "Mitali", "Karnataka", "Udaipur", 133L,
"B-26254", "4/9/2017", "Noshiba", "Karnataka", "Udaipur", 312L,
"B-26156", "4/9/2017", "Chayanika", "Madhya Pradesh", "Udaipur", 1103L)
ui <- fluidPage(
titlePanel("Plotly - dateRangeInput"),
sidebarLayout(
sidebarPanel(
pickerInput(
inputId = "state",
label = "state",
multiple = TRUE,
selected = re$State[1],
choices = c(unique(re$State))),
dateRangeInput(inputId = "date",label = "Date",
start = Sys.Date() - 28, end = Sys.Date() + 2,
format = "mm/dd/yyyy",
separator = "TO")),
mainPanel(
fluidPage(withLoader(plotlyOutput("p1"),type = "html",loader = "loader2")))))
server<-function(input,output,session){
State <- reactiveVal()
observeEvent(event_data("plotly_click", source = "State"), {
State(event_data("plotly_click", source = "State")$x)
})
output$p1 <- renderPlotly({
total %>%
count(input$state, wt = sales) %>%
plot_ly(x = input$state, y = ~n, source = "State") %>%
axis_titles() %>%
layout(title = "State")
})}
runApp(list(ui = ui, server = server), launch.browser = TRUE)