[R] about combining two dataframes
lily li
chocold12 at gmail.com
Wed May 24 19:29:46 CEST 2017
Hi all,
I have a question about combining two data frames. For example, there are
the two dataframes below, with the same structure but different column
names and column lengths. How to add the values in DF2 to the end of DF1,
though the column names do not match? How to add more than two? Thanks.
DF1
year month day product1 product2 product3
1981 1 1 18 56 20
1981 1 2 19 45 22
1981 1 3 16 48 28
1981 1 4 19 50 21
DF2
yr mon d prod prod2 prod3
1981 2 1 17 49 25
1981 2 2 20 47 23
1981 2 3 21 52 27
I use the code below but it does not work.
require(dplyr)
bind_rows(DF1, DF2) or bind_cols(DF1, DF2)
[[alternative HTML version deleted]]
More information about the R-help
mailing list