show_data: Display a table in a window

Description Usage Arguments Value Examples

View source: R/show_data.R

Description

Display a table in a window

Usage

1
2
3
4
5
6
7
8
show_data(
  data,
  title = NULL,
  options = NULL,
  show_classes = TRUE,
  type = c("popup", "modal"),
  width = "80%"
)

Arguments

data

a data object (either a matrix or a data.frame).

title

Title to be displayed in window.

options

Options passed to datatable's options argument.

show_classes

Show variables classes under variables names in table header.

type

Display table in a pop-up or in modal window.

width

Width of the window, only used if type = "popup".

Value

No value.

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
library(shiny)
library(datamods)

ui <- fluidPage(
  actionButton(
    inputId = "show1",
    label = "Show data in popup",
    icon = icon("eye")
  ),
  actionButton(
    inputId = "show2",
    label = "Show data in modal",
    icon = icon("eye")
  ),
  actionButton(
    inputId = "show3",
    label = "Show data without classes",
    icon = icon("eye")
  )
)

server <- function(input, output, session) {
  observeEvent(input$show1, {
    show_data(mtcars, title = "My data")
  })
  observeEvent(input$show2, {
    show_data(mtcars, title = "My data", type = "modal")
  })
  observeEvent(input$show3, {
    show_data(mtcars, title = "My data", show_classes = FALSE)
  })
}

if (interactive())
  shinyApp(ui, server)

datamods documentation built on July 2, 2021, 5:07 p.m.