This function returns the frequency of words.
Usage
freq(x, ..., sort = FALSE)
Arguments
- x
A character vector of words.
- ...
Must be empty. This enforces that optional arguments such as
sort are supplied with explicit names.
- sort
Whether to sort the result by descending frequency. The default
FALSE keeps the first-appearance order.
Value
A data frame with char and freq columns.
Examples
freq(c("b", "a", "b", "c", "a"))
#> char freq
#> 1 b 2
#> 2 a 2
#> 3 c 1
freq(c("b", "a", "b", "c", "a"), sort = TRUE)
#> char freq
#> 1 b 2
#> 2 a 2
#> 3 c 1