R shiny: multiple select choices. selectize and dropdownbutton setting, when multiple choices made, aggregate data collapsed -
hi i'm using both selectize , dropdownbuttons build multiple choices select widget user. works fine when single choice made, when make multiple choices, aggregate data showed incorrect. here code:
ui:
library(shiny) shinyui(fluidpage( dropdownbutton( label = "country", status = "default", width = 400, checkboxgroupinput(inputid = "var", label = "country", choices = c("all", "null", "a2", "ae", "af"), selected = c("all") ) ), hr(), dropdownbutton( label = "platform ", status = "default", width = 400, checkboxgroupinput(inputid = "plat", label = "platform ", choices = c("all", "android","ios"), selected = c("android")) ), hr(), selectizeinput(inputid ='media', label = "source", choices = c("all", "facebook", "twitter"), selected = c("all"), multiple = t), ), mainpanel( textoutput("text1") ) ))
server:
#server.r library(shiny) library(ggplot2) library(dplyr) df <- df shinyserver(function(input, output, session) { datasetinput <- reactive({ df<- df %>% filter( (input$var == 'all' | country == input$var)& (input$plat == 'all' | platform == input$plat)& (input$media == 'all' | media_source == input$media) ) }) output$text1 <- rendertext({paste("revenue: $", df() %>% summarise(revenue = sum(price)/100)}) })
when make single choice, data correct, ex) when choose facebook media, revenue 200,000, when choose twitter, revenue 50,000. want see 250,000 when choose both. however, when number quite odd when i'm doing so, got 160,000, hard know how system calculate it. same problems other 2 select widget.
btw, i'm getting warning message:
longer object length not multiple of shorter object length
anyone knows part did wrong? thank you.
Comments
Post a Comment