[R] Merging data frames on two conditions

David Winsemius dwinsemius at comcast.net
Tue Apr 6 21:59:02 CEST 2010


On Apr 6, 2010, at 3:54 PM, Abhishek Pratap 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"))

What does

  str(df1) ; str(df2)

... show?


>
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list