I'm trying to split a dataframe several times and I'm having a bit of trouble doing that. I've been trying to do this with the code below and it works for the first line of code but it doesn't go any further and I haven't quite been able to figure it out:
rs_s <- list2env(split(regular_season, regular_season$season),
.GlobalEnv)
rs_sc <- list2env(split(rs_s, rs_s$category),
.GlobalEnv)
rs_scq - list2env(split(rs_sc, rs_sc$question),
.GlobalEnv)
As I understand it, the entries in the split() function are supposed to be data frames and I have a feeling that "rs_sc" and "rs_scq" would not be considered data frames and that I might have to use a for loop but I'm not quite sure about this. If anyone has any idea, can you please help me?
EDIT: As an output, I'm hoping to have a set of mini-data frames that is indexed by the elements of "season," "category," and "question." The data frames I'm working with are much larger, but as an example, if "season" consisted of two elements
spring, fall
and "category" consisted of three elements
history, math, english
and "question" consisted of three elements
who, what, why
I'm hoping to end up with a set consisting of 18 data frames (2 seasons x 3 categories x 3 questions). If it would affect anything, my end goal right now of getting this set is to be able to run statistical regressions within the individual data frames