htmlize_datatable: HTMLize data tables

View source: R/htmlize.R

htmlize_datatableR Documentation

HTMLize data tables

Description

Add HTML styling to better display data tables.

Usage

htmlize_datatable(
  df,
  type = "basic",
  digits = 2,
  add_bttns = FALSE,
  new_width = "50px",
  ...
)

Arguments

df

Data frame. The data to be displayed.

type

String. Either 'basic' (default) or 'fancy'. Basic type removes pagination, search box and information. It only shows the data table as a plain HTML table. Fancy type keeps all these features and in addition allows you to change the width of all the columns at once.

digits

Integer. The number of digits (default = 2) to show after the decimal point for only the columns with decimal values, not the ones with all integer values.

add_bttns

Logical. If TRUE, add three buttons ('Copy', 'Print' and 'Download') to the displayed data table. Default is FALSE.

new_width

String or integer. New width of all the columns. Default is '50px'. You can also supply an integer instead of a string (for example, 50 instead of '50px').

...

Other parameters (such as rownames = F) that can be passed into 'DT::datatable()'.

Value

A 'DT::datatable()' object, which can be rendered under 'DT::renderDataTable()' and by default will show rownames.

Examples

htmlize_datatable(iris, type = 'basic', digits = 1, rownames = F)
htmlize_datatable(iris, type = 'basic', digits = 1, rownames = paste0('AA', 1:nrow(iris)))
htmlize_datatable(iris, type = 'fancy', digits = 1, add_bttns = TRUE)
htmlize_datatable(iris, type = 'fancy', digits = 1, new_width = 25)

cabaceo/shinymod documentation built on Sept. 8, 2023, 12:23 p.m.