Skip to contents

This function sets some defaults for data_styles. See ?tab_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

Value

a list of lists with 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.

Examples

library(tabelle)
# Make all booleans bold:
create_data_styles(boolean = list(test = is.logical,
                   style = openxlsx::createStyle(textDecoration = "bold")))
#> $double
#> $double$test
#> function (x)  .Primitive("is.double")
#> 
#> $double$style
#> A custom cell style. 
#> 
#>  Cell formatting: "0.00" 
#>  
#> 
#> 
#> 
#> $integer
#> $integer$test
#> function (x)  .Primitive("is.integer")
#> 
#> $integer$style
#> A custom cell style. 
#> 
#>  Cell formatting: "0" 
#>  
#> 
#> 
#> 
#> $boolean
#> $boolean$test
#> function (x)  .Primitive("is.logical")
#> 
#> $boolean$style
#> A custom cell style. 
#> 
#>  Cell formatting: GENERAL 
#>  Font decoration: BOLD 
#>  
#> 
#> 
#>