I'm looking for built-in R functions to split a data.frame
into a list of data.frames based on conditions on the column values.
To illustrate with an example, consider the data.frame
below:
date var_1 var_2
date_1 a b
date_1 b a
date_2 c b
date_2 b c
date_2 a b
date_2 b a
The specific grouping conditions are:
var_1 %in% var_2 & var_2 %in% var_1 & date == date_x
,
where date_x
runs through the unique values of date
. These conditions define the three groups:
date var_1 var_2
date_1 a b
date_1 b a
date var_1 var_2
date_2 c b
date_2 b c
date var_1 var_2
date_2 a b
date_2 b a