super_split: Split a dataframe into a list of (lists of ...) dataframes

View source: R/split.R

super_splitR Documentation

Split a dataframe into a list of (lists of ...) dataframes

Description

This function is a streamlined, recursive version of split().

Usage

super_split(.data, ...)

Arguments

.data

a dataframe

...

(unquoted) names of columns to split by

Value

a list of dataframes when splitting by a single variable, a list of lists of dataframes when splitting by 2 variables, and so on.

Examples

# some kind of 2 by 2 design
df <- data.frame(
  x =    c(1, 2, 3, 4, 5, 6, 7, 8),
  time = c(1, 1, 2, 2, 1, 1, 2, 2),
  group = c("a", "a", "a", "a", "b", "b", "b", "b")
)

super_split(df, group)

super_split(df, time)

# split by group and then split each of those by time
super_split(df, group, time)

tjmahr/printy documentation built on March 4, 2024, 1:25 a.m.