pivot_format | R Documentation |
pivot_table
Flextable format for pivot_table
pivot_format(
pivot,
background = "#81A1C1",
color = "#FFFFFF",
border = "#FFFFFF",
font_size = 11,
font_name = NULL,
labels = pivot_labels(),
formatter = pivot_formatter(),
zebra_style = c("classic", "stats", "none"),
zebra_color = "#ECEFF4",
drop_stats = FALSE,
keep_data = TRUE
)
pivot |
A |
background |
Background color for the header and column(s) containing row(s). |
color |
Text color for the header and column(s) containing row(s). |
border |
Border color (applies to all table). |
font_size |
Font size (applies to all table). |
font_name |
Font name (applies to all table). |
labels |
Custom labels for statistics, see |
formatter |
Function to format content, see |
zebra_style |
Add zebra theme to table. |
zebra_color |
Color to use for zebra theme. |
drop_stats |
Drop the stats column, can be useful if have only one stat to show. |
keep_data |
Keep data as attribute, this can be useful to retrieve the data from which the table was formatted. |
a flextable
object.
library(flexpivot)
library(magrittr)
data("nobel_laureates")
# With two variables
nobel_laureates %>%
pivot_table("category", "gender") %>%
pivot_format()
# Only count
nobel_laureates %>%
pivot_table("category", "gender", stats = "n") %>%
pivot_format(drop_stats = TRUE)
# Only percent
nobel_laureates %>%
pivot_table("category", "gender", stats = "p") %>%
pivot_format()
# Two variable as rows
nobel_laureates %>%
pivot_table(c("birth_continent", "gender"), "category", stats = "p") %>%
pivot_format()
# Without cols
pivot_format(pivot_table(nobel_laureates, rows = "category"))
pivot_format(pivot_table(nobel_laureates, rows = c("category", "gender")))
# Customize
nobel_laureates %>%
pivot_table("category") %>%
pivot_format(
background = "#A3BE8C",
labels = pivot_labels(n = "Count", p = "Percentage")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.