metan (version 1.2.1)

split_factors: Split a data frame by factors

Description

Split a data frame into subsets grouping by one or more factors.

Usage

split_factors(.data, ..., keep_factors = FALSE, verbose = TRUE)

Arguments

.data

The data that will be split. Must contain at least one grouping variable.

...

Comma-separated list of unquoted variable names that will be used to group the data.

keep_factors

If more than two factors are in the dataframe, should the columns of the non-grouping factors be kept?

verbose

Logical argument. If verbose = FALSE the code will run silently.

Value

A list where each element is a named level of the grouping factors. If more than one grouping variable is used, then each element is the combination of the grouping variables.

Details

This function is used to split a data frame into a list where each element is a level of the grouping variable (or combination of grouping variables). By combining the function split_factors with the forward-pipe operator element of the list.

Examples

Run this code
# NOT RUN {
library(metan)

g1 = split_factors(iris, Species)
g2 = split_factors(data_ge, ENV, keep_factors = TRUE)

# }

Run the code above in your browser using DataLab