我正在尝试使用 制作一个应用程序shiny,当我使用下面的代码运行该应用程序时出现错误。
错误:
\nWarning: Error in : Problem with `filter()` input `..2`.\n\xe2\x84\xb9 Input `..2` is `site == input$cueva`.\nx Input `..2` must be of size 672 or 1, not size 0.\n 202: <Anonymous>\n\nRun Code Online (Sandbox Code Playgroud)\nlibrary(shiny)\nlibrary(shinyWidgets)\n\nsampleTypeVector <- c("Tapete microbiano", "Estromatolito", "Sedimento", "Suelo")\ncaves <- c("Chimalacatepec", "Iglesia")\n\nui <- fluidPage(\n titlePanel("Taxonomic composition"),\n \n fluidRow(\n column(4, " ", \n pickerInput("sample.type", label = "Sample", \n choices = sampleTypeVector,\n multiple = TRUE,\n options = pickerOptions(\n actionsBox = TRUE\n ))),\n column(8, " ",\n pickerInput("cave", label = "Cave", \n choices = caves,\n multiple = TRUE,\n options = pickerOptions(\n actionsBox = TRUE\n )))\n ),\n fluidRow(\n column(6, " ", label = "Barplot",\n plotOutput("barplot", click = "plot_click"))\n )\n)\n\nserver <- function(input, output, session) {\n \n data <- reactive({\n phy1 %>%\n filter(sampleType == input$sample.type, site == input$cave)\n })\n \n output$barplot <- renderPlot({\n phylum_barplot(data(), sample, relativeAb, Phylum, colorsVector)#function which makes a barplot with ggpplot\n }) \n \n}\n\nshinyApp(ui = ui, server = server)\n\nRun Code Online (Sandbox Code Playgroud)\n如果我选择所有选项,我的绘图中显示的条数将少于应有的条数,如下图所示。应该是48。
\n\n我尝试修复添加的错误,sum()就像我在其他示例中看到的那样:Getting error while using ggplot with r-shiny (Warning: Error in : Problem with filter()input ..1.)。但是当我添加sum()时filter()下一个错误并且我的条形图没有出现。
Warning: Error in : Problem with `filter()` input `..1`.\n\xe2\x84\xb9 Input `..1` is `sum(sampleType == input$tipo.muestra, site == input$cueva)`.\nx Input `..1` must be a logical vector, not a integer.\n 202: <Anonymous>\nRun Code Online (Sandbox Code Playgroud)\n而且我不知道如何解决它。
\n我的数据在这里:data_shiny.csv
\n非常感谢您的宝贵时间。
\n