如何使用selectInput的输入来切片数据

时间:2019-09-24 17:01:08

标签: r shiny

我与R Shiny selectInput有类似的问题,我想使用input像这样对数据进行切片:

selectInput("category", "Choose a Category:",
                            choices = c('Any', levels(as.factor(unique(BD$DX_01_Cat))))), 

uiOutput("secondSelection")

if (input$category != "Any"){
       subsetSubsTab <<- subsetSubsTab[subsetSubsTab$DX_01_Cat==input$category];

output$secondSelection <- renderUI({
       selectInput("subdiagnosis", "Choose a Subdiagnosis:", choices = c("Any", as.character(subsetSubsTab[subsetSubsTab$DX_01_Cat==input$category, DX_01_Sub])) , selected = "Any")
     })

if (input$subdiagnosis != "Any"){
       subsetSubsTab <<- subsetSubsTab[subsetSubsTab$DX_01_Sub==input$subdiagnosis];
     }

但最后一个if statement无效。

我收到警告Warning: Error in if: argument is of length zerosubsetSubsTab实现一秒钟然后返回。有人可以帮忙吗?

0 个答案:

没有答案