ft_table {fctutils} | R Documentation |
Count Character Frequencies in Factor Levels (Including NA Handling)
Description
Counts the frequency of each character appearing in the levels of a factor vector, optionally including NA values, and returns a table or vector.
Usage
ft_table(factor_vec, case = FALSE, include_na = FALSE, as_table = TRUE)
Arguments
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 |
Value
A table or named vector of character frequencies.
Author(s)
Kai Guo
Examples
# 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)
[Package fctutils version 0.0.7 Index]