我正在尝试使用多张表格从Excel构建应用程序。它工作正常但复选框不显示,即使它实际上影响输出。我知道它会影响输出,因为当我消除了checkboxGroupInput的选定选项时,不显示任何行,否则它是预期的。也许有人可以告诉我为什么复选框没有按预期显示在侧边栏上。提前谢谢。
require('shiny') library(readxl) read_excel_allsheets <- function(filename) { sheets <- readxl::excel_sheets(filename) x <- lapply(sheets, function(X) readxl::read_excel(filename, sheet = X, range = cell_rows(c(6, NA)))) names(x) <- sheets x } data <- read_excel_allsheets("data path") ui <- fluidPage( title = "Examples of DataTables", sidebarLayout( sidebarPanel( conditionalPanel( 'input.dataset === "CUB 9"', checkboxGroupInput("show_vars", "Companies:", unique(data$'CUB 9'$Company), selected = unique(data$'CUB 9'$Company)) ), conditionalPanel( 'input.dataset === "CUP 14"', checkboxGroupInput("show_vars1", "Companies: in CUP 14", unique(data$'CUP 14'$Company), selected = unique(data$'CUP 14'$Company)) ) ), mainPanel( tabsetPanel( id = 'dataset', tabPanel("data$'CUB 9'", dataTableOutput("mytable1")), tabPanel("data$'CUP 14'", dataTableOutput("mytable2")) ) ) ) ) server <- function(input, output) { output$mytable1 <- renderDataTable({data$'CUB 9'[which(data$'CUB 9'$Company %in% c(input$show_vars)),] }) output$mytable2 <- renderDataTable({data$'CUP 14'[which(data$'CUP 14'$Company %in% c(input$show_vars1)),] }) } shinyApp(ui, server)