join two or more data frames in system R

2019-03-24 05:39发布

My questions is how can join two or more data frames in system R?

For example:

I have two data frames:

first:

   x  y  z
1  3  2  4
2  4  5  7
3  5  6  8

second:

   x  y  z
1  1  1  1
2  4  5  7

I need this:

   x  y  z
1  3  2  4
2  4  5  7
3  5  6  8
4  1  1  1
5  4  5  7

I tried to use append for each vector, like this:

for( i in 1:length(first)){

    mix[[i]]<-append(first[i], second[i])}

f<-do.call(rbind, mix)

But It didn't work like I needed. I didn't get my matrix, i got some different structure.

1条回答
贼婆χ
2楼-- · 2019-03-24 06:09

You have the right idea using rbind(), but it's much more simple. If your data frames are named "first" and "second":

f <- rbind(first, second)

And f is the new data frame.

查看更多
登录 后发表回答