Skip to contents

Creates a MDB table for a specified OU or list of OUS. Can be called in a purrr statement for batch creating

Usage

create_mdb(df, ou, type = "main", legend = NULL, legend_height = 20)

Arguments

df

data frame resulting from running reshape_mdb_df() or reshape_mdb_tx_df()

ou

operating unit for which table is to be returned

type

type of table to be created, main or treatment

legend

can pass a legend to subtitle if desired, default is NULL

legend_height

adjusts the height of the preset legend

Value

mdb_gt a gt object formatted as the main or treatment table

Examples

if (FALSE) {
 create_mdb(mdb_tbl, "Global")
 create_mdb(mdb_tbl_tx, "Zambia", type = "treatment")
 
 # Batch produce tables
 
 ou_batch <- mdb_tbl_tx %>% 
 filter(agg_type == "OU") %>% 
 distinct(operatingunit) %>% pull()
 
 purrr::map(ou_batch, ~create_mdb(mdb_tbl, ou = .x))
 
 
 # More advanced example selecting single indicator across numerous OUS
 
 create_mdb(mdb_tbl_tx %>% filter(indicator == "VLC"), 
 c("Malawi", "Zambia"), type = "treatment") %>% 
 cols_unhide(operatingunit)}