## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(shinydataviewer)
library(shiny)
library(bslib)

## ----echo = FALSE, out.width = "100%", fig.cap = "The data viewer combines per-variable summary cards with a searchable table."----
knitr::include_graphics("figures/screenshot.png")

## ----eval = FALSE-------------------------------------------------------------
# ui <- page_fillable(
#   theme = bs_theme(version = 5),
#   data_viewer_ui("viewer")
# )
# 
# server <- function(input, output, session) {
#   data_viewer_server(
#     "viewer",
#     data = reactive(iris)
#   )
# }
# 
# shinyApp(ui, server)

## ----eval = FALSE-------------------------------------------------------------
# ui <- page_fillable(
#   theme = bs_theme(version = 5),
#   layout_columns(
#     col_widths = c(4, 8),
#     card(
#       card_header("Context"),
#       card_body("Supporting content")
#     ),
#     data_viewer_card_ui(
#       "viewer",
#       title = "Dataset",
#       full_screen = FALSE
#     )
#   )
# )
# 
# server <- function(input, output, session) {
#   data_viewer_server(
#     "viewer",
#     data = reactive(mtcars)
#   )
# }
# 
# shinyApp(ui, server)

## -----------------------------------------------------------------------------
summary_df <- summarize_columns(head(iris), top_n = 4)

summary_df[c("var_name", "type", "n_missing", "n_unique")]

