ft_level_stats {fctutils} | R Documentation |
Calculate Statistics for Each Factor Level
Description
Computes statistical summaries for each level of a factor vector based on associated numeric data.
Usage
ft_level_stats(factor_vec, numeric_vec, stat_func)
Arguments
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). |
Value
A data frame with factor levels and their corresponding statistics.
Author(s)
Kai Guo
Examples
# 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)
[Package fctutils version 0.0.7 Index]