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.
精彩评论