【发布时间】:2018-03-06 20:10:04
【问题描述】:
我想知道为什么 dplyr 会产生两个不同的输出
df <- data.frame("A" = 1:10, "B" = 1:10, "C" = 1:10)
df %>% select("A") %>% count("A")
# A tibble: 1 x 2
`"A"` n
<chr> <int>
1 A 10
df %>% select(A) %>% count(A)
# A tibble: 10 x 2
A n
<int> <int>
1 1 1
2 2 1
3 3 1
4 4 1
5 5 1
6 6 1
7 7 1
8 8 1
9 9 1
10 10 1
在这种情况下,我需要第二个。我正在构建一个闪亮的应用程序,其名称带有
selectInput("variables",
choices = names(df),
selected = "A",
multiple = TRUE)
然后使用此输入创建一个带有df %>% select(input$variables) %>% count(input$variables) 的汇总表,但结果是第一个输出。
【问题讨论】: