I think you should directly use the data table to select the choices. Perhaps you can try this

ui = fluidPage(
  titlePanel(title=div(img(src="cell_image.png", height = 140, width = 400), "The Senescent Cell")),
  sidebarLayout(
    sidebarPanel( 
      uiOutput("organt"),
      uiOutput("cellt")
    ),
    mainPanel(
      tableOutput("MegaData")
    )
  )
)


server = function(input, output, session) {
  
  df1 <- veteran
  MegaP <- df1 %>% mutate(Organ=ifelse(trt==1,"Lung","Skin"))
  
  output$organt <- renderUI({
    selectInput("OrganT",
                label = "Organ",
                choices = unique(MegaP$Organ),
                multiple = T,
                selected = "All")
  })
  
  MegaP1 <- reactive({
    data <- subset(MegaP, Organ %in% req(input$OrganT))
  })
  
  output$cellt <- renderUI({
    selectInput("Cell",
                label = "Cell Line",
                choices = unique(MegaP1()$celltype),
                multiple = T,
                selected = "All")
  })
  
  selectedData <- reactive({
    req(MegaP1(),input$Cell)
    data <- subset(MegaP1(), celltype %in% input$Cell)
  })

  output$MegaData = renderTable({
    selectedData()
  })

}

shinyApp(ui = ui, server = server)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top