It looks like you are looking for split :
> split(df, df$i) $`1` ixyl 1 1 0 0 -0.56047565 2 1 0 1 -0.23017749 3 1 1 0 1.55870831 4 1 1 1 0.07050839 $`2` ixyl 5 2 0 0 0.1292877 6 2 0 1 1.7150650 7 2 1 0 0.4609162 8 2 1 1 -1.2650612
The result is a list two data.frame separated by an "i" column.
To get an array , you got a Josh response, or you can use simplify2array from the R base:
> simplify2array(by(df, df$i, as.matrix)) , , 1 ixyl 1 1 0 0 -0.56047565 2 1 0 1 -0.23017749 3 1 1 0 1.55870831 4 1 1 1 0.07050839 , , 2 ixyl 1 2 0 0 0.1292877 2 2 0 1 1.7150650 3 2 1 0 0.4609162 4 2 1 1 -1.2650612
A5C1D2H2I1M1N2O1R2T1
source share