knitr::opts_chunk$set(
  message = FALSE,
  collapse = TRUE,
  comment = "#>")
library(mRclwhip)
library(dplyr)
library(arsenal)

Formatting a data table

# Create a data set
dt <- mtcars[1:5, 1:6] %>% 
  tibble::rownames_to_column(var = "Model") %>% 
  mutate_if(is.numeric, scales::number)

format_flextable(dt)

Formatting a tableby object

tableby(arm ~ age + sex + race + bmi + fu.stat, data = mockstudy) %>%  
  format_tableby() %>% 
  add_footer("P values arise from linear models for continuous variables and Pearson's chi-squared test for categorical")

Formatting a modelsum object

modelsum(mdquality.s ~ age + bmi, data=mockstudy, adjust=~sex, family=binomial, show.adjust = F, show.intercept = F) %>%
  format_modelsum() %>% 
  add_footer("P values from logistic regression adjusting for sex.")

Adding a second header row

second_header <- list(values = c("", "Group 1", "Group 2"), colwidths = c(1,3,3))

dt %>% 
  format_flextable(header2 = second_header, bold_header = F)


overdodactyl/mRclwhip documentation built on June 30, 2023, 6:24 a.m.