Skip to contents

Add summary area to grid

Usage

grid_summary(
  grid,
  columns,
  stat = c("sum", "min", "max", "avg"),
  digits = 0,
  label = NULL,
  sep = "<br>",
  position = c("bottom", "top"),
  height = 40,
  js_function = NULL
)

Arguments

grid

A table created with datagrid().

columns

Name of column (variable name) for which to add a summary.

stat

Statistic to display: "sum", "min", "max" or "avg". Can be several values.

digits

Number of digits to display.

label

Label to display next to statistic.

sep

Separator between several statistics.

position

The position of the summary area: "bottom" or "top".

height

The height of the summary area.

js_function

JavaScript function to compute the statistic you want. Function should have one argument, it will be the values of the column. If used, stat, digits, label and sep will be ignored.

Value

A datagrid htmlwidget.

Examples

library(toastui)

# Add a line with sum of column
datagrid(ps3_games[, c(1, 5, 6, 7, 8)], colwidths = "guess") %>% 
  grid_summary(
    column = "NA_Sales",
    stat = "sum"
  )
# Do that for several columns datagrid(ps3_games[, c(1, 5, 6, 7, 8)], colwidths = "guess") %>% grid_summary( column = c("NA_Sales", "EU_Sales", "JP_Sales", "Other_Sales"), stat = "sum", label = "Total: " )