[R] combine two data-frames into one
Suyan Tian
stian at mail.rockefeller.edu
Fri Mar 14 20:43:42 CET 2008
Hi Everyone:
I need some help on combining two datasets into one. Since for those
two datasets, there are different variables. Like
In dataset 1, I have
pt x1 x2
1 12 24
2 20 17
In dataset 2, I have
pt x2 x3
3 19 33
4 20 16
The final dataset I want should look as
pt x1 x2 x3
1 12 24 NA
2 20 17 NA
3 NA 19 33
4 NA 20 16
I used setdiff and rbind together and got what I wanted, but I am
thinking there must be a simpler way to do this. Maybe just one
command or something. Please help me out.
Thanks so many,
Suyan
More information about the R-help
mailing list