checkboxRadioTables: Generate a Table with a Checkbox or Radio Button Column

Description Usage Arguments Author(s) See Also Examples

Description

The checkbox table allows for display of tabular information with the option to select multiple items for further analysis. The difference between checkboxTable and checkboxGroupTable is how the inputs are stored–the controls in a checkboxTable all have independent control names and are stored as logical. The controls in a checkboxGroupTable act as a group and the inputs are stored as a character vector. RadioTable is similar to checkboxGroupTable, but only allows the user to select one value from the table.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
checkboxGroupTable(
  tbl,
  inputId,
  label = "",
  choices,
  selected = NULL,
  table_label = "",
  control_column = 1L,
  pixie = . %>% identity(),
  display_table = FALSE,
  disabled = FALSE,
  hidden = FALSE,
  disabled_table = FALSE,
  hidden_table = FALSE
)

checkboxTable(
  tbl,
  inputId,
  label = "",
  value = FALSE,
  table_label = "",
  control_column = 1L,
  pixie = . %>% identity(),
  disabled = FALSE,
  hidden = FALSE,
  display_table = FALSE
)

radioTable(
  tbl,
  inputId,
  label = "",
  choices,
  selected = NULL,
  table_label = "",
  control_column = 1L,
  pixie = . %>% identity(),
  display_table = FALSE,
  disabled = FALSE,
  hidden = FALSE,
  disabled_table = FALSE,
  hidden_table = FALSE,
  force_default = TRUE
)

Arguments

tbl

An object that inherits data.frame

inputId

A string of length 1, as would be passed to the argument of the same name in checkboxInput.

label

A character vector of labels to appear next to the check boxes. Most often, in a tabular display, this function can be served by another table in the column and label can be left blank.

choices

List of values to show checkboxes for. If elements of the list are named then that name rather than the value is displayed to the user.

selected

The values that should be initially selected, if any. For radio buttons, this must be of length 1.

table_label

A character string to be displayed above the table.

control_column

The column position at which the check boxes should be placed.

pixie

A chain of sprinkle for customizing the appearance of the table. The chain must start with . and may take any number of commands connected by the %>% operator.

display_table

Logical. Defaults to FALSE, which converts the the table into a character string suitable for renderText. When TRUE, it prints the table to a viewing pane in order to assist the user in formatting the table without having to view it in the shiny application.

value

A logical vector setting the initial status of the check box. This must have length 1 or equal to nrow(tbl).

Author(s)

Benjamin Nutter

See Also

dust, sprinkle, checkboxInput, checkboxGroupInput, radioButtons

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
checkboxTable(tbl = mtcars,
              inputId = paste0("carChoice", 1:nrow(mtcars)),
              label = rownames(mtcars), 
              value = FALSE, 
              table_label = "Select Vehicles",
              display_table=TRUE,
              pixie = . %>% sprinkle(bg_pattern_by = "rows"))
                   
## Not run: 
library(shiny)
library(pixiedust)
library(shinydust)

server <- shinyServer(function(input, output) {
  output$table <- 
    renderText({
      cbind(rownames(mtcars), mtcars) %>%
        checkboxTable(inputId = paste0("chooseCar", 1:nrow(mtcars)),
                   label = "", 
                   value = FALSE, 
                   table_label = "Select a Vehicle",
                   pixie = . %>% 
                   sprinkle(bg_pattern_by = "rows") %>%
                   sprinkle_table(pad = 7) %>%
                   sprinkle_colnames("rownames(mtcars)" = "",
                                     control = ""))
   })
   
output$chooseCar1 <- renderText(paste0("Mazda RX4: ", input$chooseCar1))
output$chooseCar2 <- renderText(paste0("Mazda RX4 Wag: ", input$chooseCar2))
})

ui <- shinyUI(fluidPage(
  wellPanel(
    verbatimTextOutput("chooseCar1"),
    verbatimTextOutput("chooseCar2"),
    uiOutput("table")
  )
))

shinyApp(ui = ui, server = server) 

## End(Not run)




#****************************          
#* Checkbox Group Table

checkboxGroupTable(tbl = mtcars,
                   inputId = "carChoice",
                   label = rownames(mtcars), 
                   choices = paste0("car", 1:nrow(mtcars)), 
                   table_label = "Select Vehicles",
                   display_table=TRUE,
                   pixie = . %>% sprinkle(bg_pattern_by = "rows"))          
## Not run: 
library(shiny)
library(pixiedust)
library(shinydust)

server <- shinyServer(function(input, output) {
  output$table <- 
    renderText({
      cbind(rownames(mtcars), mtcars) %>%
        checkboxGroupTable(inputId = "chooseCar", 
                   label = "", 
                   choices = paste0("car", 1:nrow(mtcars)), 
                   table_label = "Select a Vehicle",
                   pixie = . %>% 
                   sprinkle(bg_pattern_by = "rows") %>%
                   sprinkle_table(pad = 7) %>%
                   sprinkle_colnames("rownames(mtcars)" = "",
                                     control = ""))
   })
   
output$choice <- renderText(input$chooseCar)
})

ui <- shinyUI(fluidPage(
  wellPanel(
    verbatimTextOutput("choice"),
    uiOutput("table")
  )
))

shinyApp(ui = ui, server = server) 

## End(Not run)


#***********************************
#* Radio Button Table
radioTable(tbl = mtcars, 
  inputId = "chooseCar", 
  label = rownames(mtcars), 
  choices = paste0("car", 1:nrow(mtcars)), 
  table_label = "Select a Vehicle",
  display_table=TRUE,
  pixie = . %>% sprinkle(bg_pattern_by = "rows"))
  
## Not run: 
library(shiny)
library(pixiedust)
library(shinydust)

server <- shinyServer(function(input, output) {
  output$table <- 
    renderText({
      cbind(rownames(mtcars), mtcars) %>%
        radioTable(inputId = "chooseCar", 
                   label = "", 
                   choices = paste0("car", 1:nrow(mtcars)), 
                   table_label = "Select a Vehicle",
                   pixie = . %>% 
                   sprinkle(bg_pattern_by = "rows") %>%
                   sprinkle_table(pad = 7) %>%
                   sprinkle_colnames("rownames(mtcars)" = "",
                                     control = ""))
   })
   
output$choice <- renderText(input$chooseCar)
})

ui <- shinyUI(fluidPage(
  wellPanel(
    verbatimTextOutput("choice"),
    uiOutput("table")
  )
))

shinyApp(ui = ui, server = server) 

## End(Not run)

nutterb/shinydust documentation built on Dec. 6, 2020, 8:13 a.m.