ft_level_stats | R Documentation |
Computes statistical summaries for each level of a factor vector based on associated numeric data.
ft_level_stats(factor_vec, numeric_vec, stat_func)
factor_vec |
A factor vector. |
numeric_vec |
A numeric vector of the same length as |
stat_func |
A function to compute the statistic (e.g., mean, median). |
A data frame with factor levels and their corresponding statistics.
Kai Guo
# Example data
factor_vec <- factor(c('A', 'B', 'A', 'B', 'C'))
numeric_vec <- c(10, 20, 15, 25, 30)
# Calculate mean for each level
ft_level_stats(factor_vec, numeric_vec, stat_func = mean)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.