ft_rollup {fctutils} | R Documentation |
Aggregate Factor Levels Based on Grouping
Description
Aggregates the levels of a factor vector based on another grouping vector.
Usage
ft_rollup(factor_vec, groups)
Arguments
factor_vec |
A factor vector to aggregate. |
groups |
A vector of the same length as |
Value
A factor vector with aggregated levels.
Author(s)
Kai Guo
Examples
# Example factor vector and groups
factor_vec <- factor(c('apple', 'banana', 'cherry', 'date', 'fig'))
groups <- c('fruit', 'fruit', 'fruit', 'dry fruit', 'dry fruit')
# Aggregate levels based on groups
ft_rollup(factor_vec, groups)
[Package fctutils version 0.0.7 Index]