pivot_calc.Rd
Title
pivot_calc(data, rows = NULL, cols = NULL, value = NULL, fun = sum, pivot = T)
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)? |
flat_titanic %>% pivot_calc(rows = sex, value = freq)#> # A tibble: 2 × 2 #> sex count #> <fct> <dbl> #> 1 Male 1731 #> 2 Female 470flat_titanic %>% pivot_calc(rows = sex, fun = mean, value = freq)#> # A tibble: 2 × 2 #> sex count #> <fct> <dbl> #> 1 Male 108. #> 2 Female 29.4