来自 Shiny 的 dplyr 多个输入

dplyr multiple inputs from Shiny

我有一个闪亮的应用程序,它从单选按钮获取输入,然后使用它在服务器端使用 dplyr 对数据框执行过滤。它有效,但现在我想扩展它以接受多个输入进行过滤,但我不知道该怎么做。

为了说明,在ui.R

中是这样的
radioButtons(
  inputId = "selectPrincipal",
  choices = c("a", "b", "c")
)

然后在 server.R 中选择像这样

output$PrincipalValue <- renderText({
  x <- df %>%
    filter(Principal==input$selectPrincipal) %>%
    summarize(total=sum(Value))
  prettyNum(x$total, big.mark=",")
})

df 会包含这样的内容

> df
Source: local data frame [10 x 2]

   Principal Value
1          a     4
2          a     1
3          a     1
4          a     3
5          b     4
6          b     2
7          b     2
8          b     3
9          c     2
10         c     1

以上设置有效。现在说我想介绍一个新的单选按钮选择,叫做 "All"。在上面的 server.R 中,我应该将什么值传递给 filter(Principal==dplyr中是否有通配符来过滤保留所有?或者是否有另一种方法等效于连接所有值(虽然我无法弄清楚语法)?

在某种程度上,我猜 this question 在 RODBC 上询问来自 shiny 的多个输入,但我想知道 dplyr.

是否有不同的方法
Principal == input$selectPrincipal | input$selectPrincipal == "All"