闪亮 - 错误:“filter()”输入“..1”出现问题

geo*_*bio 2 r shiny

我正在尝试使用 制作一个应用程序shiny,当我使用下面的代码运行该应用程序时出现错误。

\n

错误:

\n
Warning: 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\n
Run Code Online (Sandbox Code Playgroud)\n
library(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\n
Run Code Online (Sandbox Code Playgroud)\n

如果我选择所有选项,我的绘图中显示的条数将少于应有的条数,如下图所示。应该是48。

\n

在此输入图像描述

\n

我尝试修复添加的错误,sum()就像我在其他示例中看到的那样:Getting error while using ggplot with r-shiny (Warning: E​​rror in : Problem with filter()input ..1.)。但是当我添加sum()filter()下一个错误并且我的条形图没有出现。

\n
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>\n
Run Code Online (Sandbox Code Playgroud)\n

而且我不知道如何解决它。

\n

我的数据在这里:data_shiny.csv

\n

非常感谢您的宝贵时间。

\n

Adr*_*nte 12

我最近发布了一个与您类似的问题,解决方案是使用%in%而不是==in filter()。也许它也能解决你的问题。