--- title: "Constructing tables" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Constructing tables} %\VignetteEncoding{UTF-8} %\VignetteEngine{knitr::rmarkdown} editor_options: chunk_output_type: console --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` ```{r, echo=TRUE, message=FALSE, warning=FALSE} library(gapminder) library(dplyr) library(tidyr) library(stringr) library(purrr) library(gt) library(mmtable2) ``` ## Adding headers You can add headers using data from a column in your data frame. Its placement will depend on your your choice of header_* functions. Header options include: top, top_left, left, and left_top. Here's an example. ```{r message=FALSE, warning=FALSE, echo = T} style_list <- list(cell_borders(sides = "top",color = "grey")) style_list2<- list(cell_borders(sides = "left",color = "grey")) gm_df <- gapminder_mm %>% filter(var != "Life expectancy") style_list3 = list(cell_text(align = "left")) gm_table <- gm_df %>% mmtable(cells = value) + header_left(year) + header_top(country) + header_left_top(var) + header_top_left(continent) + header_format(header = var, scope = "table", style = style_list) + header_format(continent,style_list3) print(gm_table) ```