Learn R Programming

stackoverflow (version 0.7.0)

rsplit: Recursivly split a data.frame

Description

When there are multiple factors to split by, Base R split returns a flattened structure by splitting on the interaction of all factors. rsplit instead returns a nested list-of-lists.

Usage

rsplit(x, by, drop = FALSE)

Arguments

x

a data.frame or vector

by

a data.frame of factors

drop

drop unused factor levels

Value

a nested list of dataframes, split by each element of by

Inspired by, but different from the below

References

https://stackoverflow.com/questions/47802545/converting-data-frame-into-deeply-nested-list/47802935#47802935