ft_table | R Documentation |
Counts the frequency of each character appearing in the levels of a factor vector, optionally including NA values, and returns a table or vector.
ft_table(factor_vec, case = FALSE, include_na = FALSE, as_table = TRUE)
factor_vec |
A factor vector whose levels will be analyzed. |
case |
Logical. Should the character count be case-sensitive? Default is |
include_na |
Logical. Should NA levels be included in the character count? Default is |
as_table |
Logical. Should the result be returned as a table? If |
A table or named vector of character frequencies.
Kai Guo
# Example factor vector with NA levels
factor_vec <- factor(c('apple', 'banana', NA, 'cherry', 'date', NA, 'fig', 'grape'), exclude = NULL)
# Get character frequencies (case-insensitive), excluding NA levels
ft_table(factor_vec)
# Include NA levels in the character frequencies
ft_table(factor_vec, include_na = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.