0

I have 2 data frames of unequal length:

>df1
Sample col1   col2   col3   col4
ca100  15000  100     99     101
cb75   17899   99    101     103
cc50   19000  103     78     222 
ca40   23000   89    333     389
ca30    567   3444    67     34

>df2
names      ca   cb   cc   cd
Intercept 7.8   4.3  7.8  9.3 
coeff-a   4.5   6.7  5.4  2.3 
coeff-b   4.9   8.3  8.4  9.3

They have unequal number of rows and I want to merge them such that the 3 rows of df2 are beside the 1st 3 rows of df1 and no NA below it

Expected result:

Sample  col1   col2   col3   col4   names      ca     cb    cc    cd
ca100  15000   100     99     101   Intercept 7.8     4.3  7.8   9.3
ca75   17899    99     101    103   coeff-a   4.5     6.7  5.4   2.3
ca50   19000   103     78     222   coeff-b   4.9     8.3  8.4   9.3
ca40   23000    89     333    389
ca30   567     3444    67     34

Is there a way to do it? I couldn't figure out from any past questions how to merge these without generating NA cause ultimately I want to export this data frame as a csv file.

Debjyoti
  • 177
  • 1
  • 1
  • 9

0 Answers0