create_data_styles: create_data_styles

View source: R/tab_styles.R

create_data_stylesR Documentation

create_data_styles

Description

This function sets some defaults for data_styles. See ?tbl_styles

Usage

create_data_styles(
  double = list(test = is.double, style = openxlsx::createStyle(numFmt = "0.00")),
  integer = list(test = is.integer, style = openxlsx::createStyle(numFmt = "0")),
  ...
)

Arguments

double

style for columns of type double

integer

style for columns of type integer

...

add further styles

Details

Styles are applied to the columns in the data set based on their classes (e.g., numeric, character, etc.). data_styles must be a list of lists. Each inner list must have two elements: a "test" that is used to determine the class of a data colum (e.g., is.double) and a style that is then applied to the columns where the test returns TRUE. Note that styles will be applied in the order of the list, meaning that a later style may overwrite an earlier style.

Value

a list of lists with styles

Examples

library(tablespan)
# Make all booleans bold:
create_data_styles(boolean = list(test = is.logical,
                   style = openxlsx::createStyle(textDecoration = "bold")))

tablespan documentation built on April 3, 2025, 9:21 p.m.