Skip to contents

Generate a factor with custom levels and repetitions.

Usage

fct_generator(labels, nlevels)

Arguments

labels

A character vector specifying the custom labels for the factor levels.

nlevels

An integer or a vector of integers indicating the number of repetitions for each label. If a single integer is provided, it is recycled to match the length of labels. If a vector is provided, it should have the same length as labels.

Value

A factor with custom levels and repetitions.

Details

This function creates a factor with custom labels and specified repetitions for each label.

Examples

# Example usage of the function
fct_generator(labels = c("A", "B", "C"), nlevels = 3)
#> $A
#> [1] 3
#> 
#> $B
#> [1] 3
#> 
#> $C
#> [1] 3
#> 
#> attr(,"class")
#> [1] "fct_names"