knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(ggrrr)
out = outputter(tempdir(check = TRUE),datedFile = FALSE,datedSubdirectory = FALSE)

Create a table from a tibble

This is a wrapper

simpleTable = tibble(
  Type = c("apples","pears","bananas"),
  Quantity = c(21,34,15)
)

tmp = simpleTable %>% hux_default_layout() %>% hux_save_as(out("t1"), std_size$third)
tmp
summary = diamonds %>% filter(cut %in% c("Fair","Good")) %>% group_by(cut,color,clarity) %>% summarise(
  `average size (carat)` = sprintf("%1.2f [%1.2f \u2014 %1.2f]", mean(carat), mean(carat)-1.96*sd(carat), mean(carat)+1.96*sd(carat)),
  `median price` = sprintf_list("%1.0f [%1.0f \u2014 %1.0f]", quantile(price, c(0.5,0.25,0.75)))
)



table = summary %>% hux_tidy(colGroupVars = vars(cut), rowGroupVars = vars(color, clarity))
table
# this saves the table into a multipage pdf and multiple png files (one per page). This is based on a full A4 page size, minus margins which demonstrates the overflow onto 
# a second page.
table %>% hux_default_layout(defaultFontSize = 8) %>% hux_save_as(out("multipage_t2"), std_size$full)
fs::dir_tree(out(),glob="*/multipage*")


terminological/ggrrr documentation built on June 15, 2024, 6:35 a.m.