[R] Merging data frames on two conditions

Gabor Grothendieck ggrothendieck at gmail.com
Wed Apr 7 02:54:50 CEST 2010


Yes, indexing will typically make a large difference.

On Tue, Apr 6, 2010 at 3:54 PM, Abhishek Pratap <abhishek.vit at gmail.com> wrote:
> Hi Guys
>
> I have two data frames which I would like to merge on two conditions.
>
> I am doing the following  (abstract form)
>
> new.data.frame <- merge(df1,df2, by=c("Col1","Col2"))
>
> It is giving me a null result.
>
> Basically I need to apply two conditions.
>
> I also tried sqldf but it is running forever. Will indexing help ?
>
> temp <- sqldf("select a.chr,a.SNP,a.snp_qual,a.rms_qual,a.depth,b.rsid FROM
> + data_lane6_snps a,
> + data_lane6_snps_rsid b
> + WHERE
> + a.SNP = b.SNP
> + AND
> + a.chr = b.chr
> + ")
>
> Thanks!
> -Abhi
>
>        [[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.
>



More information about the R-help mailing list