View source: R/two-column-layouts.R
gt_double_table | R Documentation |
The gt_double_table
function takes some data and a user-supplied
function to generate two tables in a list. To convert existing gt::gt()
code to a function, you can follow the approximate pattern:
gt_fn <- function(x){gt(x) %>% more_gt_code}
Your function should only have a single argument, which is the data
to be supplied directly into the gt::gt()
function. This function is
intended to be passed directly into gt_two_column_layout()
, for printing
it to the viewer, saving it to a .png
, or returning the raw HTML.
gt_double_table(data, gt_fn, nrows = NULL, noisy = TRUE)
data |
A |
gt_fn |
A user-defined function that has one argument, this argument should pass data to the |
nrows |
The number of rows to split at, defaults to |
noisy |
A logical indicating whether to return the warning about not supplying |
a list()
of two gt
tables
library(gt) # define your own function my_gt_function <- function(x) { gt(x) %>% gtExtras::gt_color_rows(columns = mpg, domain = range(mtcars$mpg)) %>% tab_options(data_row.padding = px(3)) } two_tables <- gt_double_table(mtcars, my_gt_function, nrows = 16) # list of two gt_tbl objects # ready to pass to gtExtras::gt_two_column_layout() str(two_tables, max.level = 1) #> List of 2 #> $ :List of 16 #> ..- attr(*, "class")= chr [1:2] "gt_tbl" "list" #> $ :List of 16 #> ..- attr(*, "class")= chr [1:2] "gt_tbl" "list"
2-13
Other Utilities:
add_text_img()
,
fa_icon_repeat()
,
fmt_pad_num()
,
fmt_pct_extra()
,
fmt_symbol_first()
,
generate_df()
,
gt_add_divider()
,
gt_badge()
,
gt_duplicate_column()
,
gt_fa_column()
,
gt_fa_rank_change()
,
gt_fa_rating()
,
gt_fa_repeats()
,
gt_highlight_cols()
,
gt_highlight_rows()
,
gt_img_border()
,
gt_img_circle()
,
gt_img_multi_rows()
,
gt_img_rows()
,
gt_index()
,
gt_merge_stack_color()
,
gt_merge_stack()
,
gt_two_column_layout()
,
gtsave_extra()
,
img_header()
,
pad_fn()
,
tab_style_by_grp()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.