我有这个声明,让我得到关于我的变量的基本描述性统计:
checkboxGroupInput('show_vars', 'Columns in diamonds to show:',
names(input_data), selected = names(input_data))
Run Code Online (Sandbox Code Playgroud)
但是,在不得不取消10个变量以获得我感兴趣的一个变量之后,我意识到这个用户界面不是很友好.我想添加一个按钮,单击它时选择/取消选择所有按钮.它可以多次点击.我甚至不确定如何开始.任何推动都会有所帮助.
ui.R:
library(shiny)
hw<-diamonds
shinyUI(fluidPage(
title = 'Examples of DataTables',
sidebarLayout(
sidebarPanel(
checkboxGroupInput('show_vars', 'Columns in diamonds to show:',
names(hw), selected = names(hw))
),
mainPanel(
verbatimTextOutput("summary"),
tabsetPanel(
id = 'dataset',
tabPanel('hw', dataTableOutput('mytable1'))
)
)
)
))
Run Code Online (Sandbox Code Playgroud)
server.R:
library(shiny)
data(diamonds)
hw<-diamonds
shinyServer(function(input, output) {
output$summary <- renderPrint({
dataset <- hw[, input$show_vars, drop = FALSE]
summary(dataset)
})
# a large table, reative to input$show_vars
output$mytable1 <- renderDataTable({
library(ggplot2)
hw[, input$show_vars, drop = …Run Code Online (Sandbox Code Playgroud)