[R] how to stack a list of arrays
Ernest Adrogué
nfdisco at gmail.com
Thu Nov 24 00:46:18 CET 2011
Hello,
I have this list of 2-d arrays:
$`0`
k d
[1,] 0.2011962 4.019537
[2,] 0.2020706 5.722719
[3,] 0.2029451 7.959612
$`1`
k d
[1,] 0.3148325 2.606903
[2,] 0.3160287 3.806665
[3,] 0.3172249 5.419222
$`2`
k d
[1,] 0.2332536 4.949390
[2,] 0.2342188 7.115258
[3,] 0.2351840 9.955909
which I need to transform into a data frame like this one:
k d group
[1,] 0.2011962 4.019537 0
[2,] 0.2020706 5.722719 0
[3,] 0.2029451 7.959612 0
[1,] 0.3148325 2.606903 1
[2,] 0.3160287 3.806665 1
[3,] 0.3172249 5.419222 1
[1,] 0.2332536 4.949390 2
[2,] 0.2342188 7.115258 2
[3,] 0.2351840 9.955909 2
Is there any R function that I can use? I know stack() but it only
works with vectors.
Thank you!
Ernest
More information about the R-help
mailing list