【发布时间】:2017-06-01 04:56:28
【问题描述】:
我正在尝试添加一个下拉菜单来操作我的数据框。
例如,
假设我的 df 有列 - a1 a2 a3 b1 b2 c1 c2 c3
我想添加一个下拉菜单,其中包含选择 = list("All", "a", "b", "c") 将过滤表格以包含所有列、以 a 开头或以开头的列以此类推。
不知道该怎么做。可以创建新的 df 以在选择选项时调用,也可以根据选择操作 df。
这是一些示例代码(不是我的真实代码):
library(shiny)
shinyUI(fluidPage(
titlePanel("x"),
sidebarLayout(
sidebarPanel(
selectInput(inputId = "x",
choices = list("All", "a", "b", "c"))
),
mainPanel(
dataTableOutput('x')
)
)
))
#dfa <- data.frame(select(df, starts_with("a")))
#dfb <- data.frame(select(df, starts_with("b")))
#dfc <- data.frame(select(df, starts_with("c")))
shinyServer(function(input, output) {
output$x = renderDataTable({
?????
})
})
【问题讨论】:
标签: r shiny shiny-server