format_my_table: Format a knitr table nicely

Description Usage Arguments Examples

Description

This function creates nicely formatted tables in R Markdown documents. It is designed to work with data formatting functions from the "formattable" package. Remember that columns formating must be applied before calling the format_my_table().

Usage

1
2
format_my_table(df, format = NA, width = FALSE, font_size = 12,
  scroll_box = NA, fit_to_page = NULL, filter = "none")

Arguments

df

A data frame

format

Select the kable format. Possible options are: NA (default) which is equivalent to "html", "latex" and "DT"

width

Should the table have full-page width? Defaults to FALSE

font_size

What font size should be used? Defaults to 12

scroll_box

Should the table be enframed in a scroll-box? Defaults to NA. This option is very usefull when dealing with long tables. Must be used as character in the following format "600px"

fit_to_page

Should the table be scaled to page in "latex" tables. Possible options are: NA (default) and "scale_down"

filter

Whether column filtering should be enabled. For posible options plese check ?DT::datatable

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
recipes::credit_data %>%
  first_to_lower() %>%
  calculate_share(job) %>%
  format_my_table()

recipes::credit_data %>%
  first_to_lower() %>%
  calculate_share(job) %>%
  mutate(
     share   = formattable::percent(share, 2),
     n_group = formattable::color_tile("white", "orange")(n_group)
  ) %>%
  format_my_table()

recipes::credit_data %>%
   first_to_lower() %>%
   calculate_share(job) %>%
   mutate(n_group = formattable::color_tile("white", "red")(n_group)) %>%
   format_my_table("DT")

konradsemsch/aider documentation built on May 22, 2019, 2:40 p.m.