format_databars: Add Databars to the Datatable

Description Usage Arguments Value See Also Examples

View source: R/datatable_EZ.R

Description

Applies conditional formatting databars to one or more columns in a DT::datatable().

Usage

1
format_databars(table, columns, color = "Pastel1", min_quantile = 0.1)

Arguments

table

an object from DT::datatable or finTrendr::datatable_EZ output

columns

columns to be formatted (can be character or a formula of the form ~ V1 + V2, which is equivalent to c('V1', 'V2'))

color

Background colors for each column (recycled if needed). One of:

  • One of RColorBrewer::brewer.pal() qualitative palettes ('Accent', 'Dark2','Paired', 'Pastel1', 'Pastel2', 'Set1', 'Set2', 'Set3'), or a numeric index 1-8 of those names. The default is "Pastel1"

  • valid R color name(s) - like "red3"

  • RGB value(s) - like "rgb(255, 0, 0)"

  • HEX value(s) - like "#ff0000"

min_quantile

Controls the minimum length of the databar. The row with the maximum value in a column will always have a full bar. The row with the minimum value will have a zero-length bar, if min_quantile=0. Default is 0.10.

Value

Formatted DT::datatable object

See Also

datatable_EZ, datatable, formatStyle, styleColorBar

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
dt <- iris %>% datatable_EZ()

# multiple columns specification
# same as c("Sepal.Length","Petal.Length")
dt %>% format_databars(~ Sepal.Length + Petal.Length)

# Specify R color names
dt %>% format_databars(~ Sepal.Length, color=c("red3","grey75"))

# Specify RColorBrewer qualitative palettes
dt %>% format_databars(~ Sepal.Length, color= "Pastel1") # by name
dt %>% format_databars(~ Sepal.Length, color= 2) # by index

vadimus202/datatableEZ documentation built on May 3, 2019, 2:41 p.m.