I have a list with this structure:
$ List (length 13) ; 13 Types
$ --- Lists (Length 4) ; Each have 4 subsets of the same original data
$ ------- Dataframes 1, 2, 3, and 4 ; for each of 13 types
I want
$ List (length 52) ; 52 Versions (Type_Subset)
$ --- Dataframes 1, 2, 3, ... 52 ; As separate elements in list
How would I do this using the below mtcars
example?
df <- list(Blue = list(mtcars[1:3,], mtcars[4:6,], mtcars[7:9,]),
Red = list(mtcars[10:12,], mtcars[13:15,], mtcars[16:18,]),
Green = list(mtcars[18:20,], mtcars[21:23,], mtcars[24:26,]))
# Need function on df ...
# new_df <- SingleNestLevel(df)
# Which yields:
list(Blue1 = mtcars[1:3,],
Blue2 = mtcars[4:6,],
Blue3 = mtcars[7:9,],
Red1 = mtcars[10:12,],
Red2 = mtcars[13:15,],
Red3 = mtcars[16:18,],
Green1 = mtcars[18:20,],
Green2 = mtcars[21:23,],
Green3 = mtcars[24:26,])
Note: I have looked at analogous questions like this one, but I want to convert to one nested level, not flatten my structure entirely.