0

I have these two data frames:

df1

|year |month | mort_rate 
 -----------------------  
 2019  April   .18
 2019  My      .30
  .     .        .
  .     .        .

df2

|year |month | mort_rate 
 -----------------------  
 2020  April   .18
 2020  My      .30
  .     .        .
  .     .        .

I would like to have a data frame like this

df3

|year |month | mort_rate | year |   month | mort_rate 
 ----------------------------------------------------- 
 2019  April   .18         2020     April
 2019  My      .30          2020    May
  .     .        .
  .     .        .

I tried with this:

df3 <- cbind(df1, df2)

And I have this result:

Error in data.frame(..., check.names = FALSE) : 
  arguments imply differing number of rows: 9, 8

I know that the shape of my data frame is different but i would like to know if is possiple append two different data frames in a horizontally way.

Thanks

coding
  • 917
  • 2
  • 12
  • 25
  • how do you want it to deal with the differing numbers of rows? – Ben Bolker Aug 09 '20 at 19:38
  • only if you create NA values to match the number of rows. Also, please put the data frame's creation call when you make a question so it's easy for us to reproduce the problem. – daniellga Aug 09 '20 at 19:41

0 Answers0