[R] merge 2 data frame based on more than 2 variables

2006-08-14 Thread Wensui Liu
Dear Lister, I understand merge() can be used to join 2 data frames based on 1 variable. But how about merge based on more than 2 variables? Thank you so much! -- WenSui Liu (http://spaces.msn.com/statcompute/blog) Senior Decision Support Analyst Health Policy and Clinical Effectiveness

Re: [R] merge 2 data frame based on more than 2 variables

2006-08-14 Thread Simon Blomberg
Wensui Liu wrote: Dear Lister, I understand merge() can be used to join 2 data frames based on 1 variable. But how about merge based on more than 2 variables? Thank you so much! Just specify the 2 (or more) variable names in a column vector for by) merge(dat1, dat2, by= c(VarA, VarB))

Re: [R] merge 2 data frame based on more than 2 variables

2006-08-14 Thread Wensui Liu
what if the names are different in 2 data frames? On 8/14/06, Simon Blomberg [EMAIL PROTECTED] wrote: Wensui Liu wrote: Dear Lister, I understand merge() can be used to join 2 data frames based on 1 variable. But how about merge based on more than 2 variables? Thank you so much!

Re: [R] merge 2 data frame based on more than 2 variables

2006-08-14 Thread Simon Blomberg
Then instead of by, use by.x and by.y to specifiy the variable names separately for both data frames. See ?merge, especially the examples. Wensui Liu wrote: what if the names are different in 2 data frames? On 8/14/06, Simon Blomberg [EMAIL PROTECTED] wrote: Wensui Liu wrote: