I have this statement that lets me get basic descriptive statistics about my variables:
checkboxGroupInput(\'show_vars\', \'Columns in diamonds to show:\',
I added a global.R
for loading packages and data - not always necessary but it's generally cleaner. There might be different ways to do what I did below, but I tend to use conditional panels in situations like this.
library(shiny)
shinyUI(fluidPage(
title = 'Examples of DataTables',
sidebarLayout(
sidebarPanel(
radioButtons(
inputId="radio",
label="Variable Selection Type:",
choices=list(
"All",
"Manual Select"
),
selected="All"),
conditionalPanel(
condition = "input.radio != 'All'",
checkboxGroupInput(
'show_vars',
'Columns in diamonds to show:',
choices=names(hw),
selected = "carat"
)
)
),
mainPanel(
verbatimTextOutput("summary"),
tabsetPanel(
id = 'dataset',
tabPanel('hw', dataTableOutput('mytable1'))
)
)
)
))
library(shiny)
library(ggplot2)
##
shinyServer(function(input, output) {
Data <- reactive({
if(input$radio == "All"){
hw
} else {
hw[,input$show_vars,drop=FALSE]
}
})
output$summary <- renderPrint({
## dataset <- hw[, input$show_vars, drop = FALSE]
dataset <- Data()
summary(dataset)
})
# a large table, reative to input$show_vars
output$mytable1 <- renderDataTable({
Data()
## hw[, input$show_vars, drop = FALSE]
})
})
library(shiny)
library(ggplot2)
data(diamonds)
hw <- diamonds