Title: | Create and combine tables with a ggplot2/patchwork syntax |
---|---|
Description: | Add headers using data from a column in your data frame. Combine tables with +, / and * operators. Output tables in gt package format. |
Authors: | Ian Moran |
Maintainer: | Ian Moran <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.3 |
Built: | 2024-11-20 03:36:39 UTC |
Source: | https://github.com/ianmoran11/mmtable2 |
Integrate two tables horizontally
## S3 method for class 'mmtable' mmtable1 * mmtable2
## S3 method for class 'mmtable' mmtable1 * mmtable2
mmtable1 |
an mmtable |
mmtable2 |
an mmtable |
an mmtable
Concatenate tables horizontally
## S3 method for class 'mmtable' e1 / e2
## S3 method for class 'mmtable' e1 / e2
e1 |
an mmtable |
e2 |
an mmtable |
an mmtable
Integrate two tables horizontally
## S3 method for class 'mmtable' mmtable1 + mmtable2
## S3 method for class 'mmtable' mmtable1 + mmtable2
mmtable1 |
an mmtable |
mmtable2 |
an mmtable |
an mmtable
Add cells formatting
add_cells_format(mmtable, ...)
add_cells_format(mmtable, ...)
mmtable |
an mmtable object |
... |
arguments for add_cells_format |
an mmtable
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
Add formatting to a header
add_header_format(mmtable, ...)
add_header_format(mmtable, ...)
mmtable |
an mmtable object |
... |
arguments for add_header_format |
an mmtable
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
Add a left header
add_header_left(mmtable, ...)
add_header_left(mmtable, ...)
mmtable |
an mmtable object |
... |
arguments for header_left |
an mmtable object
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
Add a left top header
add_header_left_top(mmtable, ...)
add_header_left_top(mmtable, ...)
mmtable |
an mmtable object |
... |
arguments for header_left_top |
an mmtable object
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
Add a top header
add_header_top(mmtable, ...)
add_header_top(mmtable, ...)
mmtable |
an mmtable object |
... |
arguments for header_top |
an mmtable object
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
Add a top left header
add_header_top_left(mmtable, ...)
add_header_top_left(mmtable, ...)
mmtable |
an mmtable object |
... |
arguments for header_top_left |
an mmtable object
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
Add a spanner to a table
add_spanner(gm_table2, spanner_list)
add_spanner(gm_table2, spanner_list)
gm_table2 |
a mmtable |
spanner_list |
a list of spannner calls |
mmtable
Add formatting to a table
add_table_format(mmtable, ...)
add_table_format(mmtable, ...)
mmtable |
an mmtable object |
... |
arguments for table_format |
an mmtable
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
## Not run: library(tidyverse) gm_table_piped <- gapminder_mm %>% filter(var != "Life expectancy") %>% mmtable(cells = value, use_defaul_formats = T) %>% add_header_top(year) %>% add_header_left(country) %>% add_header_top_left(var) %>% add_header_left_top(continent) %>% add_cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) %>% add_header_format(header = year, style = list(cell_text(align = "right"))) %>% add_header_format("all_cols", style = list(cell_text(weight = "bolder"))) %>% add_header_format("all_rows", style = list(cell_text(weight = "bolder"))) %>% add_table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) %>% add_table_source_note(source_note = "Excerpt of the Gapminder dataset." ) gm_table_piped ## End(Not run)
Add a table source note
add_table_source_note(mmtable, ...)
add_table_source_note(mmtable, ...)
mmtable |
an mmtable object |
... |
arguments of gt::tab_source_note |
an mmtable
Apply formating to a mmtable
apply_format(mmtable, format_list)
apply_format(mmtable, format_list)
mmtable |
an mmtable |
format_list |
a list of styles of the same format as the gt::tab_style list argument https://gt.rstudio.com/reference/tab_style.html. |
mmtable
Apply list of formating commands to a mmtable
apply_formats(mmtable)
apply_formats(mmtable)
mmtable |
an mmtable |
mmtable
Conditionally apply a function
apply_if(predicate, func, data, ...)
apply_if(predicate, func, data, ...)
predicate |
a predicate |
func |
a function to apply |
data |
data used by the function or otherwise returned |
... |
other objects involved in evaluation of the function |
data
Format table cells
cells_format(cell_predicate, ...)
cells_format(cell_predicate, ...)
cell_predicate |
an expression on the source data frame identifying which cells should be formatted. |
... |
dots. |
format list
## Not run: gm_table_formatted <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) + header_format(header = year, style = list(cell_text(align = "right"))) + header_format("all_cols", style = list(cell_text(weight = "bolder"))) + header_format("all_rows", style = list(cell_text(weight = "bolder"))) + table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) + table_source_note(source_note = "Excerpt of the Gapminder data" ) ## End(Not run)
## Not run: gm_table_formatted <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + cells_format(cell_predicate = T, style = list(cell_text(align = "right"))) + header_format(header = year, style = list(cell_text(align = "right"))) + header_format("all_cols", style = list(cell_text(weight = "bolder"))) + header_format("all_rows", style = list(cell_text(weight = "bolder"))) + table_format( locations = cells_body(rows = c(1,3,5,7,9,11)), style = list(cell_borders(sides = "top",color = "grey"))) + table_source_note(source_note = "Excerpt of the Gapminder data" ) ## End(Not run)
Remove adjacent repeats in a dataframe
diagonalize(df, var_char)
diagonalize(df, var_char)
df |
a data frame |
var_char |
the column to be diagonalized |
data frame
Extract the largest binary rectary from a list of rows and cols
extract_max_rects(extraction_list)
extract_max_rects(extraction_list)
extraction_list |
a list containting a dataframe of rows and cols and a list of already extracted rows and cols. |
extraction_list
Apply formatting to a location
format_a_loc(mmtable, loc, format_list)
format_a_loc(mmtable, loc, format_list)
mmtable |
an mmtable |
loc |
a list containing a row and col items |
format_list |
a list of formatting commands |
format list
Excerpt of the Gapminder data on life expectancy, GDP per capita, and population by country.
gapminder_mm
gapminder_mm
A data frame with 53940 rows and 10 variables:
price, in US dollars
weight of the diamond, in carats
weight of the diamond, in carats
weight of the diamond, in carats
weight of the diamond, in carats
... continent country value var year
Generate a random string
gen_random_ids(n, length)
gen_random_ids(n, length)
n |
number of ids |
length |
length of id |
format list
Identify which locations are to be formatted.
get_locations( mmtable, header = NULL, func, cell_predicate = NULL, scope = "cell" )
get_locations( mmtable, header = NULL, func, cell_predicate = NULL, scope = "cell" )
mmtable |
an mmtable |
header |
header from original data |
func |
the original formatting function applied |
cell_predicate |
predicate to determine locations |
scope |
string determining how widely formating will apply. Options include "cell", "headers" and "table" |
locations
An algorthm to identify the largest rectangle in a histogram
get_max_area_bf(heights)
get_max_area_bf(heights)
heights |
a list of the heights of the histogram. |
list
Get row header names.
get_row_header_names(df, col_header_df_01)
get_row_header_names(df, col_header_df_01)
df |
a dataframe |
col_header_df_01 |
a dataframe of col headers |
a vector of names
Get the html associated with a spanner
get_spanner_html_text(table)
get_spanner_html_text(table)
table |
an mmtable |
html
Format the cells of a header.
header_format(header, ...)
header_format(header, ...)
header |
the name of a variable that is currently a header in the table |
... |
a list of styles, with format required by gt::tab_style style argument. https://gt.rstudio.com/reference/tab_style.html |
format list
Add a left header
header_left(variable)
header_left(variable)
variable |
a column of the data frame from which header values will be constructed |
an mmtable object
## Not run: library(tidyverse) row_list <- cells_body(rows = c(1,3,5,7,9,11)) style_list <- list(cell_borders(sides = "top",color = "grey")) gm_df <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") gm_table <- gm_df %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + table_format( locations = row_list, style = style_list) ## End(Not run)
## Not run: library(tidyverse) row_list <- cells_body(rows = c(1,3,5,7,9,11)) style_list <- list(cell_borders(sides = "top",color = "grey")) gm_df <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") gm_table <- gm_df %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + table_format( locations = row_list, style = style_list) ## End(Not run)
Add a left top header
header_left_top(variable)
header_left_top(variable)
variable |
a column of the data frame from which header values will be constructed |
an mmtable object
## Not run: library(tidyverse) row_list <- cells_body(rows = c(1,3,5,7,9,11)) style_list <- list(cell_borders(sides = "top",color = "grey")) gm_df <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") gm_table <- gm_df %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + table_format( locations = row_list, style = style_list) ## End(Not run)
## Not run: library(tidyverse) row_list <- cells_body(rows = c(1,3,5,7,9,11)) style_list <- list(cell_borders(sides = "top",color = "grey")) gm_df <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") gm_table <- gm_df %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + table_format( locations = row_list, style = style_list) ## End(Not run)
Merge header columns
header_merged_cols(...)
header_merged_cols(...)
... |
formating instructions |
format list
Add a top header
header_top(variable)
header_top(variable)
variable |
a column of the data frame from which header values will be constructed |
an mmtable object
## Not run: library(tidyverse) row_list <- cells_body(rows = c(1,3,5,7,9,11)) style_list <- list(cell_borders(sides = "top",color = "grey")) gm_df <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") gm_table <- gm_df %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + table_format( locations = row_list, style = style_list) ## End(Not run)
## Not run: library(tidyverse) row_list <- cells_body(rows = c(1,3,5,7,9,11)) style_list <- list(cell_borders(sides = "top",color = "grey")) gm_df <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") gm_table <- gm_df %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + table_format( locations = row_list, style = style_list) ## End(Not run)
Add a top left header
header_top_left(variable)
header_top_left(variable)
variable |
a column of the data frame from which header values will be constructed |
an mmtable object
## Not run: library(tidyverse) row_list <- cells_body(rows = c(1,3,5,7,9,11)) style_list <- list(cell_borders(sides = "top",color = "grey")) gm_df <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") gm_table <- gm_df %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + table_format( locations = row_list, style = style_list) ## End(Not run)
## Not run: library(tidyverse) row_list <- cells_body(rows = c(1,3,5,7,9,11)) style_list <- list(cell_borders(sides = "top",color = "grey")) gm_df <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") gm_table <- gm_df %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + table_format( locations = row_list, style = style_list) ## End(Not run)
Print an mmtable object
knit_print.mmtable(x, ...)
knit_print.mmtable(x, ...)
x |
an mmtable |
... |
other things |
Create an mmtable object
mmtable( data, cells, table_name = NULL, use_default_formats = TRUE, table_data = NULL )
mmtable( data, cells, table_name = NULL, use_default_formats = TRUE, table_data = NULL )
data |
a data frame |
cells |
the name of the column whose values will form the data cells. |
table_name |
the name of the table - used for labeling when joined with another table - randomly generated if not provided. |
use_default_formats |
determines whether or note the table will have default formatting applied. Default value = TRUE. |
table_data |
deprecated. Use 'cells' instead. |
mmtable
## Not run: library(tidyverse) row_list <- cells_body(rows = c(1,3,5,7,9,11)) style_list <- list(cell_borders(sides = "top",color = "grey")) gm_df <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") gm_table <- gm_df %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + table_format( locations = row_list, style = style_list) ## End(Not run)
## Not run: library(tidyverse) row_list <- cells_body(rows = c(1,3,5,7,9,11)) style_list <- list(cell_borders(sides = "top",color = "grey")) gm_df <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") gm_table <- gm_df %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + table_format( locations = row_list, style = style_list) ## End(Not run)
Print an mmtable object
## S3 method for class 'mmtable' print(x, ...)
## S3 method for class 'mmtable' print(x, ...)
x |
an mmtable |
... |
other things |
Set the class of an object
set_class(object, class)
set_class(object, class)
object |
a object |
class |
new class of object |
mmtable
Convert a list of cells to a list of cell ranges
single_cells_to_vector(row_col_list)
single_cells_to_vector(row_col_list)
row_col_list |
list of cells |
Sort and select columns
sort_and_select_columns(data, ...)
sort_and_select_columns(data, ...)
data |
a data frame |
... |
list of data to load into envrionment |
mmtable
Convert header to spanner
spannerize(gm_table2, n)
spannerize(gm_table2, n)
gm_table2 |
a mmtable |
n |
number of spanners |
mmtable
Spread rows to columns
spread_col_headers(data, ...)
spread_col_headers(data, ...)
data |
a data frame |
... |
list of data to load into envrionment |
a data frame
A dataset containing the prices and other attributes of almost 54,000 diamonds.
student_df
student_df
A data frame with 53940 rows and 10 variables:
...
A dataset containing the prices and other attributes of almost 54,000 diamonds.
student_df_1
student_df_1
A data frame with 53940 rows and 10 variables:
...
A dataset containing the prices and other attributes of almost 54,000 diamonds.
student_df_2
student_df_2
A data frame with 53940 rows and 10 variables:
...
Style the first col header
style_first_col_header(table, format)
style_first_col_header(table, format)
table |
a data frame |
format |
a data frame |
a data frame
Style a spanner
style_spanner(table, format)
style_spanner(table, format)
table |
an gt_tbl |
format |
formatting |
a data frame
Use attributes to construct a table with column and row headers.
table_constructor( df, col_header_df, row_header_df, data_vars, table_name = NULL, table_format )
table_constructor( df, col_header_df, row_header_df, data_vars, table_name = NULL, table_format )
df |
a data frame |
col_header_df |
col header information |
row_header_df |
row header information |
data_vars |
cell variable |
table_name |
name of the table |
table_format |
formatting o the table |
mmtable
Format a mmtable object.
table_format(locations, ...)
table_format(locations, ...)
locations |
indicating which cells should be formatted. |
... |
formating instructions |
format list
## Not run: library(tidyverse) row_list <- cells_body(rows = c(1,3,5,7,9,11)) style_list <- list(cell_borders(sides = "top",color = "grey")) gm_df <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") gm_table <- gm_df %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + table_format( locations = row_list, style = style_list) ## End(Not run)
## Not run: library(tidyverse) row_list <- cells_body(rows = c(1,3,5,7,9,11)) style_list <- list(cell_borders(sides = "top",color = "grey")) gm_df <- gapminder_mm %>% dplyr::filter(var != "Life expectancy") gm_table <- gm_df %>% mmtable(cells = value) + header_top(year) + header_left(country) + header_top_left(var) + header_left_top(continent) + table_format( locations = row_list, style = style_list) ## End(Not run)
Table source note
table_source_note(...)
table_source_note(...)
... |
arguments of gt::tab_source_note |
format list
Add a table title
table_title(...)
table_title(...)
... |
arguments of gt::tab_header |
format list
A dataset containing the prices and other attributes of almost 54,000 diamonds.
table1
table1
A data frame with 53940 rows and 10 variables:
...
Transfer spanner from one table to another
transfer_spanner(gt_01, gt_02)
transfer_spanner(gt_01, gt_02)
gt_01 |
arguments of gt::tab_source_note |
gt_02 |
arguments of gt::tab_source_note |
an mmtable