r - selectInput can't populate duplicate values (using uiOutput and renderUI) in Shiny -


i have shiny app based on dataframe looks this:

  id       date      result   1      1/1/2010    100   1      12/12/2010  200   2      1/1/2011    300   2      1/1/2011    400 

notice double id's...and id 2, 2 dates same.

when running, app looks this:

enter image description here

but app gets confused when forced consider id #2, has multiple of same dates:

enter image description here

the dropdown menu has blank first choice, second choice populated correct.

how correct this, dropdown populated number of identical dates?

(the more think this, feeling bug opposed wrangling functionality out of object. isn't hard think of numerous situations duplicate values of interest.)

thanks attention.

app.r

library('shiny')  df <- data.frame(id=c(1,1,2,2), date=c('1/1/2010', '12/12/2010', '1/1/2011', '1/1/2011'), result=c(100, 200, 300, 400)) df$date <- as.character(df$date)    server <- function(input, output, session) {    get_id <- reactive({     id <- df[which(df$id == input$id), ]     return(id)})    output$result <- rendertext({      ans <- get_id()     print(ans)     paste("result: ", ans$result)})     output$dates<-renderui({     print(get_id()$date)     selectinput('dates', 'select date:', choices=get_id()$date, selected=get_id()$date[1])}) }  ui <- fluidpage(   fluidrow(column(2,       numericinput(inputid="id", label="pick id: ", value=1))),            column(2,        uioutput("dates")),           column(3, mainpanel(textoutput("result"))) )  shinyapp(ui = ui, server = server) 

i not sure why isn't showing, there get-around situation. use parameter selectize = false in selectinput() function. should give desired functionality.

selectinput('dates', 'select date:', choices=get_id()$date,selected=get_id()$date, selectize = false)}) 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -