开发者

join two or more data frames in system R

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜