Hello, I'm trying to update pickerInput choices using loop and observeEvent. Below approach works with assigning reactive values, but not updatePickerInput.
library(shiny)
ui <- fluidPage(
fluidRow(
column(
width = 6,
lapply(
X = 1:6,
FUN = function(i) {
sliderInput(inputId = paste0("num", i), label = i, min = 0, max = 10, value = i)
}
)
),
column(
width = 6,
lapply(
X = 1:6,
FUN = function(i) {
pickerInput(inputId = paste0("pick", i), label = i, choices = seq(1, i))
}
)
)
)
)
server <- function(input, output, session){
lapply(
X = 1:6,
FUN = function(i){
observeEvent(input[[paste0("num", i)]], {
updatePickerInput(
session,
input[[paste0("pick", i)]],
choices = seq(1:input[[paste0("num", i)]])
)
})
}
)
}
shinyApp(ui = ui, server = server)
Any kind of guideline would be very much helpful.