[R] convert list to data frame

From: Judy Chung <cp3942_at_gmail.com>
Date: Mon 05 Dec 2005 - 23:08:54 EST


Dear R users:

   I've a list containing parameters (A , B & C), and I want create a data frame using data in these list.
 > coffee
[[1]]

        A     B        C
1       1   0.5  7.78
2       1   1.0  6.06
3       1   2.0  3.67
4       1   4.0  1.35
5       1   6.0  0.49
6       1   8.0  0.18

[[2]]
         A   B        C
1       2   5    7.78
2       2   10  6.06
3       2   20  3.67
4       2   40  1.35
5       2   60  0.49
6       2   80  0.18


> as.data.frame(do.call("rbind",coffee))
A B C 1 1 0.5 7.78 2 1 1.0 6.06 3 1 2.0 3.67 4 1 4.0 1.35 5 1 6.0 0.49 6 1 8.0 0.18 11 2 5 7.78 21 2 10 6.06 31 2 20 3.67 41 2 40 1.35 51 2 60 0.49 61 2 80 0.18 But I want the form like this: A B C 1 1 0.5 7.78 2 1 1.0 6.06 3 1 2.0 3.67 4 1 4.0 1.35 5 1 6.0 0.49 6 1 8.0 0.18 7 2 5 7.78 8 2 10 6.06 9 2 20 3.67 10 2 40 1.35 11 2 60 0.49 12 2 80 0.18

How would I do this?
Please give me some comments.
Thanks in advance!!



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Dec 05 23:20:16 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:28 EST