I need some help regarding the rbind function in R. I have the following 2 dataframes.
df1
col1 col2 col3
row1 0 1 0
row2 txt1 txt2 txt3
row3 txtA txtB txtC
row4 51 93 83
df2
col1 col2 col3
row5 0.732 0.345 0.532
row6 0.453 0.123 0.456
row7 0.656 0.987 0.321
row8 0.432 0.030 0.754
I want to merge these 2 dataframes, so I use rbind function to get the following:
col1 col2 col3
row1 0 1 0
row2 txt1 txt2 txt3
row3 txtA txtB txtC
row4 51 93 83
row5 0.732 0.345 0.532
row6 0.453 0.123 0.456
row7 0.656 0.987 0.321
row8 0.432 0.030 0.754
However, that's not what I get. When I used merge <- rbind(df1,df2), I get
col1 col2 col3
row1 0 1 0
row2 txt1 txt2 txt3
row3 txtA txtB txtC
row4 51 93 83
row5 <NA> <NA> <NA>
row6 <NA> <NA> <NA>
row7 <NA> <NA> <NA>
row8 <NA> <NA> <NA>
So, when I merge these 2 dataframes, I get NA values for the df2. Could anyone help me with getting this right?
Thanks in advance!