Convert list into a data.frame

时间:2015-06-26 09:34:59

标签: r list

I have a list names f.And I have a matrix dataasli.

 >f
 [[1]]
  [1]    NA 13481 13938 14846 15399 15534 15534 15892 16835 17726 16538 15399
 [13] 15534 15150 15205 16011 16835 17726 19060 19331 19335 18900

 [[2]]
  [1]    NA 13608 13913 14696 15467 15331 15646 15882 16826 17075 16388 15467
 [13] 15331 15331 15191 16002 16863 18150 19030 19330 19336 18892

 [[3]]
  [1]    NA 13545 13900 14771 15433 15433 15636 15877 16821 17036 16463 15433
 [13] 15433 15148 15184 15998 16849 18225 19015 19330 19336 18888

 [[4]]
  [1]    NA 13608 13893 14696 15467 15359 15629 15874 16819 17013 16388 15413
 [13] 15522 15147 15180 15995 16863 18150 19006 19329 19337 18886

 [[5]]
  [1]    NA 13566 13888 14746 15445 15422 15625 15872 16817 16997 16438 15445
 [13] 15422 15147 15177 15993 16854 18200 19000 19329 19337 18884



 > dataasli
   [,1]<br>
  [1,] 13055<br>
  [2,] 13563<br>
  [3,] 13867<br>

I would like to merge or cbind dataasli and f to a data.frame like so:

   Actual | 1|2|3|4|5
  [1,] 13055|NA|NA|NA|NA|NA
  [2,] 13563|13481|13608|13544|13608
  [3,] 13867|19398|13912|13900|13892

How would I go to accomplish this?

1 个答案:

答案 0 :(得分:0)

Try

cbind(dataasli, do.call(cbind, f))