【发布时间】:2019-05-02 15:28:30
【问题描述】:
我正在构建一个 Rshiny 应用程序,其中输入数据将始终具有相同的结构但不同的类别。无论这些数据是什么样子,我总是希望我的过滤器显示相同的值。我遵循了一些示例并认为这会起作用,但我无法设置默认选择。
此外,我很好奇当我在过滤器中为我的绘图和表格使用这些备用显示名称时,是否需要对 服务器 做任何事情,或者这只是对 Ui 的纯粹编辑?
The data would have a structure like this,
but the values of "col_1" and "col_2" will always differ.
No matter what those values are, I always want the first value of "col_1"
to appear in the Ui "Filter 1" as "Segment 1" and the first
value of "col_2" to appear as "Group A" in "Filter 2" and so on...
col_1 <- c("Seg 1", "Seg 2")
col_2 <- c("A", "B")
x<-data.frame(Seg, Group)
#My ui looks something like this
....
pickerInput("Segment", "Filter 1",
choices = c("Segement 1" =(x$Seg[1])[1],
"Segment 2" = (x$Seg[2])[2]),
selected = 'Segment 1', multiple = TRUE),
cellWidths = c("10%", "89%")
),
pickerInput("product_line", "Filter 2", multiple = TRUE,
choices = c("Product A" = levels(x$Group[1]),
"Product B" = levels(x$Goup[2])),
selected = "Product A"),
....
【问题讨论】:
标签: r filter shiny selection shiny-server