数据帧上的R滤波器
我需要在我闪亮的应用程序的数据框上应用一个过滤器。 我正在寻找一些按钮(小的一个),打开一个特定列的值的多选列表。类似于Excel的表过滤器 例如(来自):数据帧上的R滤波器,r,shiny,R,Shiny,我需要在我闪亮的应用程序的数据框上应用一个过滤器。 我正在寻找一些按钮(小的一个),打开一个特定列的值的多选列表。类似于Excel的表过滤器 例如(来自): 库(闪亮) 闪亮::runApp(列表( ui=fluidPage( checkboxGroupInput(“物种”、“物种”,选项=级别(虹膜$物种)), 表格输出(“内容”) ), 服务器=功能(输入、输出、会话){ output$content这将为您提供大部分信息,但一旦您选择了一个选项,它就无法隐藏复选框: library(sh
库(闪亮)
闪亮::runApp(列表(
ui=fluidPage(
checkboxGroupInput(“物种”、“物种”,选项=级别(虹膜$物种)),
表格输出(“内容”)
),
服务器=功能(输入、输出、会话){
output$content这将为您提供大部分信息,但一旦您选择了一个选项,它就无法隐藏复选框:
library(shiny)
shiny::runApp(list(
ui = fluidPage(
actionButton("show_checkbox", "Show Choices"),
uiOutput("checkbox"),
tableOutput("content")
),
server = function(input, output, session) {
output$checkbox <- renderUI({
if ( is.null(input$show_checkbox) ) { return(NULL) }
if ( input$show_checkbox == 0 ) { return(NULL) }
return(checkboxGroupInput("specy", "Specy", choices = levels(iris$Species)))
})
output$content <- renderTable({
if ( is.null(input$specy) ) { return(iris) }
if ( length(input$specy) == 0 ) { return(iris) }
iris[iris$Species == input$specy, ]
})
}
))
库(闪亮)
闪亮::runApp(列表(
ui=fluidPage(
操作按钮(“显示复选框”、“显示选项”),
uiOutput(“复选框”),
表格输出(“内容”)
),
服务器=功能(输入、输出、会话){
输出$checkbox我很清楚,您是否在寻找一种方法,使复选框仅在单击按钮时显示?完全正确!并在应用过滤器后隐藏感谢快速回答。我们是否可以用类似toggleButton的内容替换actionButton?我在“shinyBS”中找到它:bsButton(…,type=“toggle”)
要通过第二次单击收回列表,请将输出$checkbox
中的第二个条件更改为输入$show\u checkbox%%2==0
。但是,重新打开它将重新初始化筛选。
library(shiny)
shiny::runApp(list(
ui = fluidPage(
actionButton("show_checkbox", "Show Choices"),
uiOutput("checkbox"),
tableOutput("content")
),
server = function(input, output, session) {
output$checkbox <- renderUI({
if ( is.null(input$show_checkbox) ) { return(NULL) }
if ( input$show_checkbox == 0 ) { return(NULL) }
return(checkboxGroupInput("specy", "Specy", choices = levels(iris$Species)))
})
output$content <- renderTable({
if ( is.null(input$specy) ) { return(iris) }
if ( length(input$specy) == 0 ) { return(iris) }
iris[iris$Species == input$specy, ]
})
}
))