1

Estoy intentando hacer un updateselectinput pero no funciona correctamente. Cuando cambio el input de datalab_data, las opciones en el selectinput datalab_columns no cambian y se mantienen con los nombres de columnas de Events. Espero q podais ayudarme con esta parte del codigo:

header <- dashboardHeader(
  title = "dashboard_shiny", titleWidth = 250
)

sidebar <- dashboardSidebar(
  width = 250,
  sidebarMenu(
    menuItem("Data Lab", tabName = "datalab", icon = icon("flask"))
  )
)

body <- dashboardBody(
  tabItems(
    tabItem("datalab",
            fluidRow(
              column(6, wellPanel(radioButtons("datalab_data", "Select data source:", choices = c("Events", "Worknotes", "Occupations")))),
              column(6, wellPanel(selectInput("datalab_columns", "Select data columns:", choices = "All Columns", multiple = T)))
            )
           )
  )
)

ui <- dashboardPage(header, sidebar, body)

server <- function(input, output, session) {

observeEvent(input$datalab_data != "", {
    
    if(input$datalab_data == "Events"){
      columns <- events() %>% colnames()
    }
    
    if(input$datalab_data == "Worknotes"){
      columns <- worknotes() %>% colnames()
    }
    
    if(input$datalab_data == "Occupations"){
      columns <- occupations() %>% colnames()
    }
    
    updateSelectInput(session = session, inputId = "datalab_columns", choices = c("All Columns", columns), selected = "All Columns")
    
  })

}

shinyApp(ui, server)
2

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.