R等我想将列表中的几个矩阵组合成一个矩阵

时间:2014-01-08 10:24:02

标签: r list matrix

我想将列表中的几个矩阵组合成一个大矩阵。我确信这是显而易见的,但我让我对R编程很感兴趣。我已尝试使用unlist功能进行多次尝试,但无济于事。任何帮助,将不胜感激。以下是清单:

> list(allele.freq.locus.p)
[[1]]
[[1]]$locus1.allele1
[[1]]$locus1.allele1$`123`
           locus  population allele number heterozygote 
1 locus1.allele1 population1    123     17            3 
7 locus1.allele1 population2    123     10            6 
8 locus1.allele1 population3    123      6            2 

[[1]]$locus1.allele1$`145`
           locus  population allele number heterozygote 
2 locus1.allele1 population1    145      7            3 
4 locus1.allele1 population2    145     10            4 
6 locus1.allele1 population3    145     11            3 

[[1]]$locus1.allele1$`165`
           locus  population allele number heterozygote 
3 locus1.allele1 population1    165      0            0 
5 locus1.allele1 population2    165     10            6 
9 locus1.allele1 population3    165      1            1 


[[1]]$locus2.allele1
[[1]]$locus2.allele1$`233`
            locus  population allele number heterozygote 
10 locus2.allele1 population1    233      7            7 
14 locus2.allele1 population2    233     21            9 
16 locus2.allele1 population3    233      9            9 

[[1]]$locus2.allele1$`235`
            locus  population allele number heterozygote 
11 locus2.allele1 population1    235      3            3 
12 locus2.allele1 population2    235      3            3 
18 locus2.allele1 population3    235      0            0 

[[1]]$locus2.allele1$`245`
            locus  population allele number heterozygote 
13 locus2.allele1 population1    245     14           10 
19 locus2.allele1 population2    245      3            3 
20 locus2.allele1 population3    245      9            9 

[[1]]$locus2.allele1$`256`
            locus  population allele number heterozygote 
15 locus2.allele1 population1    256      0            0 
17 locus2.allele1 population2    256      3            3 
21 locus2.allele1 population3    256      0            0 


[[1]]$locus3.allele1
[[1]]$locus3.allele1$`123`
            locus  population allele number heterozygote 
23 locus3.allele1 population1    123      8            4 
24 locus3.allele1 population2    123     10            8 
30 locus3.allele1 population3    123      6            4 

[[1]]$locus3.allele1$`145`
            locus  population allele number heterozygote 
25 locus3.allele1 population1    145      7            7 
27 locus3.allele1 population2    145     11            7 
29 locus3.allele1 population3    145      5            3 

[[1]]$locus3.allele1$`176`
            locus  population allele number heterozygote 
22 locus3.allele1 population1    176      9            5 
26 locus3.allele1 population2    176      9            7 
28 locus3.allele1 population3    176      7            5 

我想生成一个如下所示的矩阵:

       locus  population allele number heterozygote 
1 locus1.allele1 population1    123     17            3 
7 locus1.allele1 population2    123     10            6 
8 locus1.allele1 population3    123      6            2 
2 locus1.allele1 population1    145      7            3 
4 locus1.allele1 population2    145     10            4 
6 locus1.allele1 population3    145     11            3 
3 locus1.allele1 population1    165      0            0 
5 locus1.allele1 population2    165     10            6 
9 locus1.allele1 population3    165      1            1 
10 locus2.allele1 population1    233      7            7 
14 locus2.allele1 population2    233     21            9 
16 locus2.allele1 population3    233      9            9 
11 locus2.allele1 population1    235      3            3 
12 locus2.allele1 population2    235      3            3 
18 locus2.allele1 population3    235      0            0 
13 locus2.allele1 population1    245     14           10 
19 locus2.allele1 population2    245      3            3 
20 locus2.allele1 population3    245      9            9 
15 locus2.allele1 population1    256      0            0 
17 locus2.allele1 population2    256      3            3 
21 locus2.allele1 population3    256      0            0 
23 locus3.allele1 population1    123      8            4 
24 locus3.allele1 population2    123     10            8 
30 locus3.allele1 population3    123      6            4 
25 locus3.allele1 population1    145      7            7 
27 locus3.allele1 population2    145     11            7 
29 locus3.allele1 population3    145      5            3 
22 locus3.allele1 population1    176      9            5 
26 locus3.allele1 population2    176      9            7 
28 locus3.allele1 population3    176      7            5 

1 个答案:

答案 0 :(得分:3)

这些看起来像是data.frame,但并不重要:

do.call("rbind", list.of.data)