Nothing
knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(presenter) library(dplyr)
Transpose a tibble of summary statistics in tidy format. Convenient function for transposing the output of dplyr"s group_by
and summarize
operation.
Transpose a 1 row numerical summary:
wide format
iris %>% summarize(across(where(is.numeric), mean), .groups = "drop") -> sumr0 sumr0
long format
sumr0 %>% pivot_summary()
A grouped summary can be transposed by providing the name of the group column.
wide format
iris %>% group_by(Species) %>% summarize(across(where(is.numeric), mean), .groups = "drop") -> sumr1 sumr1
long format
sumr1 %>% pivot_summary(Species)
Supports transposing numerical summaries with multiple groups using tidyselect.
long format
iris %>% mutate(Species1 = sample(Species)) %>% group_by(Species, Species1) %>% summarize(across(where(is.numeric), mean), .groups = "drop") -> sumr2 sumr2
Group names are concatenated and pivoted.
wide format
sumr2 %>% pivot_summary(matches("Spec"))
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.