split_factors: Split a data frame by factors

Description Usage Arguments Details Value Author(s) Examples

View source: R/split_factors.R

Description

[Stable]

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

This function is used to split a data frame into a named list where each element is a level of the grouping variable (or combination of grouping variables).

Usage

1
2
3
4
5
split_factors(.data, ..., keep_factors = FALSE)

as.split_factors(.data, keep_factors = FALSE)

is.split_factors(x)

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 split the data.

keep_factors

Should the grouping columns be kept?

x

An object to check for class split_factors.

Details

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.

Author(s)

Tiago Olivoto tiagoolivoto@gmail.com

Examples

1
2
3
4
5
6
7
8
library(metan)

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

spdata <- as.split_factors(iris)

is.split_factors(spdata)

metan documentation built on Nov. 10, 2021, 9:11 a.m.