compute frequency table.
Arguments
- data
a data frame
- ...
One or more unquoted expressions (or variable names) separated by commas. Used to specify variables of interest.
- vars
optional character vector containing variable names.
- na.rm
logical value. If TRUE (default), remove missing values in the variables used to create the frequency table.
Examples
data("ToothGrowth")
ToothGrowth %>% freq_table(supp, dose)
#> # A tibble: 6 × 4
#> supp dose n prop
#> <fct> <dbl> <int> <dbl>
#> 1 OJ 0.5 10 33.3
#> 2 OJ 1 10 33.3
#> 3 OJ 2 10 33.3
#> 4 VC 0.5 10 33.3
#> 5 VC 1 10 33.3
#> 6 VC 2 10 33.3
# Grouped data: frequencies are computed within each group
ToothGrowth %>% group_by(supp) %>% freq_table(dose)
#> Adding missing grouping variables: `supp`
#> # A tibble: 6 × 4
#> supp dose n prop
#> <fct> <dbl> <int> <dbl>
#> 1 OJ 0.5 10 33.3
#> 2 OJ 1 10 33.3
#> 3 OJ 2 10 33.3
#> 4 VC 0.5 10 33.3
#> 5 VC 1 10 33.3
#> 6 VC 2 10 33.3