add_theme: Add a theme to the tableHTML

add_themeR Documentation

Add a theme to the tableHTML

Description

add_theme will add a theme to tableHTML

Usage

add_theme(tableHTML, theme = c("scientific", "rshiny-blue", "colorize"), ...)

Arguments

tableHTML

A tableHTML object.

theme

Pick one of the provided themes. These can still be modified by extra css. Choices are: scientific, rshiny-blue, colorize. Column widths are not provided when you select a theme. Please use the width argument for column widths.

...

Additional parameters to pass to the theme. Currently "colorize" is the only theme that takes additional parameters. For more details on those parameters see add_theme_colorize.

Details

add_theme will add a theme to tableHTML.

Value

A tableHTML object.

Examples

tableHTML(mtcars,
          rownames = FALSE,
          widths = c(140, rep(50, 11)),
          row_groups = list(c(10, 10, 12), c('Group 1', 'Group 2', 'Group 3')),
          second_headers = list(c(3, 4), c('col1', 'col2'))) %>%
  add_theme('scientific')

tableHTML(mtcars, widths = c(140, rep(50, 11))) %>%
  add_theme ('rshiny-blue')

mtcars %>%
  tableHTML(widths = c(150, rep(50, 11)),
            rownames = TRUE) %>%
  add_theme('colorize')

generate_df <- function(){
  df <- data.frame(Month = month.abb,
                   x1 = sample(1:100, 12),
                   x2 = sample(1:100, 12),
                   x3 = sample(1:100, 12),
                   stringsAsFactors = FALSE)
  df[nrow(df) + 1, ] <- c('Total', sum(df$x1), sum(df$x2), sum(df$x3))
  return(df)
}
df_1 <- generate_df()
df_2 <- generate_df()

rbind(df_1, df_2) %>%
  tableHTML(widths = rep(50, 4), rownames = FALSE) %>%
  add_theme('colorize', total_rows = c(13, 26),
            color = c('steelblue', 'green3'), id_column = TRUE)

LyzandeR/tableHTML documentation built on April 17, 2023, 3:57 p.m.