pivot_formatter | R Documentation |
pivot_format
Formatters for pivot_format
pivot_formatter(
n = round,
p = function(x) { paste0(round(x, 1), "%") },
p_col = function(x) { paste0(round(x, 1), "%") },
p_row = function(x) { paste0(round(x, 1), "%") }
)
n |
Function, applied to n. |
p |
Function, applied to p. |
p_col |
Function, applied to p_col. |
p_row |
Function, applied to p_row. |
a list
of function
s that can be use in pivot_format
.
library(flexpivot)
data("nobel_laureates")
# One variable
pt <- pivot_table(nobel_laureates, rows = "category")
pivot_format(pt)
pivot_format(pt, formatter = pivot_formatter(
n = function(x) {
format(round(x * 100), big.mark = " ")
}
))
# Two variable as rows
pt <- pivot_table(nobel_laureates, rows = c("category", "gender"))
pivot_format(pt)
pivot_format(pt, formatter = pivot_formatter(
n = function(x) {
format(round(x * 100), big.mark = " ")
}
))
# One row, one column
pt <- pivot_table(nobel_laureates, rows = "category", cols = "gender")
pivot_format(pt)
pivot_format(pt, formatter = pivot_formatter(
n = function(x) {
format(round(x * 100), big.mark = " ")
}
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.