Title

pivot_prop(
  data,
  rows = NULL,
  cols = NULL,
  value = NULL,
  fun = sum,
  within = NULL,
  pivot = T,
  percent = T,
  round = F
)

Arguments

data

A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details.

rows

a character vector of items

cols

a character vector of items

pivot

logical: should wide table be returned - col categories as columns (TRUE), or left long and tidy (FALSE)?

Value

Examples

tidy_titanic %>% pivot_prop(rows = sex, cols = survived, within = sex)
#> # A tibble: 2 × 3 #> sex No Yes #> <fct> <dbl> <dbl> #> 1 Male 78.8 21.2 #> 2 Female 26.8 73.2