[R] An R clause to bind dataframes under certain contions

Wensui Liu liuwensui at gmail.com
Sat Jan 26 21:37:10 CET 2008


Hi, Huali,
there is another way to do so

library(sqldf)
wanted <- sqldf("select * from X inner join Y on X.A = Y.A and X.B = Y.A")

2008/1/26 zhihuali <lzhtom at hotmail.com>:
>
> Hi netters,
> Suppose I have two data frames X and Y. X has three colnames A, B and C. Y has three colnames A,B and D.
>
> I want to combine them into one matrix, joining the rows having the same A and B values (X$A==Y$A and X$B = Y$B). So the resulting dataframe has four variables/columns: A,B,C and D.
>
> I was wondering what's the best way to do it in R.  Could anyone give me some advice?
>
> Thanks!
>
> Zhihua Li
>
>
> _________________________________________________________________
> 手机也能上 MSN 聊天了,快来试试吧!
>
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
===============================
WenSui Liu
Statistical Project Manager
ChoicePoint Precision Marketing
(http://spaces.msn.com/statcompute/blog)
===============================


More information about the R-help mailing list