cloudspotter86
9/28/2018 - 5:29 PM

flextable

install.packages("flextable")
library(flextable)
library(officer)

myft <- regulartable(
  head(mtcars), 
  col_keys = c("am", "carb", "gear", "mpg", "drat" ))
myft

theme_vanilla(myft)



myft <- merge_v(myft, j = c("am", "carb") )
myft

myft = set_header_labels(myft, carb = "# carb.")
myft = width(myft, width = .75)

myft

myft <- italic(myft, j = 1)
myft <- bg(myft, bg = "#C90000", part = "header")
myft <- color(myft, color = "white", part = "header")
myft

myft <- color(myft, ~ drat > 3.5, ~ drat, color = "red")
myft <- bold(myft, ~ drat > 3.5, ~ drat, bold = TRUE)
myft <- autofit(myft)

myft


regulartable(gender_table) %>% set_formatter_type(fmt_double = "%0.1f") %>% 
  align(part = "header", align = "right") %>% 
  bg(bg = "#E6E6E6", part = "header") %>% bold(part = "header") %>% width(j = ~ Gender, width = 1.75) %>%
  theme_zebra() # themes are: vanilla, zebra, box, booktabs