knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
tablecloth
library(tablecloth) library(dplyr) library(gtsummary) library(mice) library(flextable)
apa_theme()
data(mtcars) m1 <- lm(mpg ~ cyl + qsec + wt, mtcars) %>% tbl_regression() %>% modify_column_hide(column = ci) m2 <- lm(mpg ~ cyl + disp + qsec + wt, mtcars) %>% tbl_regression() %>% modify_column_hide(column = ci) m3 <- lm(mpg ~ cyl + disp + hp + qsec + wt, mtcars) %>% tbl_regression() %>% modify_column_hide(column = ci) tbl_merge( tbls = list(m1, m2, m3)) %>% apa_theme()
mice_df
data(nhanes) imp <- mice::mice(nhanes, m = 5, print = FALSE) vs <- c("bmi", "chl", "age") nm <- c("BMI", "Cholesterol", "Age") title <- "Table 1: Descriptive statistics" mice_df(imp = imp, vs = vs, title = title, nm = nm)
mice_cor
data(nhanes) imp <- mice::mice(nhanes, m = 5, print = FALSE) vs <- c("bmi", "chl", "age", "hyp") title <- "Table 2: Correlation matrix" mice_cor(imp = imp, vs = vs, title = title)
# Making a hexsticker! # library(hexSticker) #library(showtext) #font_add_google("Gentium Book Basic", "booky") #table <- # tbl_merge( # tbls = list(m1, m2, m3)) %>% # apa_theme() #stick <- table %>% # color(color = "white", part = "all") %>% # flextable::hline_top(border = officer::fp_border(width = 4, color = "white"), part = "all") %>% # flextable::hline_bottom(border = officer::fp_border(width = 4, color = "white"), part = "all") %>% # flextable::hline(i = 1, border = officer::fp_border(width = 2, color = "white"), part = "header") %>% # fontsize(size = 32, part = "all") #stick <- as_raster(stick) #sticker(stick, # package = "tablecloth", # s_x = 1, s_y = .8, s_width = 1.2, s_height = 1.2, # p_size = 8, p_y = 1.3, # h_fill = "#638aa1", h_color = "#73bddc", # p_family = "booky", # filename = "sticker.png")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.