Use this function to calculate simple weighted frequencies. You can also specify a grouping variable by which you want to calculate the frequencies.
The x
, group
, and wt
arguments can either be strings or symbols
(meaning they can have quotes or no quotes). The benefit of this is that it
makes it really easy to iterate this function over a list or vector of
variables with other functions like purrr::map()
purrr::map()
or purrr::walk()
purrr::walk()
that are found in the purrr
package.
Arguments
- data
An object of type data.frame or tibble. If piping the data into the function, this is not required.
- x
Either a character string or symbol. The variable with which want to get the frequencies.
- group
<
tidy-select
> A selection of columns to group the data by in addition totreats
. This operates very similarly to.by
from dplyr (for more info on that see ?dplyr_by).- wt
Weights. Add if you have a weighting variable and want to get weighted frequencies.
- drop_zero
Logical. Determines if rows with 0 should be removed Default is
FALSE
.- decimals
Number of decimals each number should be rounded to. Default is 3.
- na.rm
Logical. Determines if NAs should be kept or removed Default is
TRUE
.