comparing data frames
3
0
Entering edit mode
@straubhaar-juerg-391
Last seen 10.3 years ago
I have two data frames with a name column containing affy probeset ids. I would like to pull out the ids (just the ids) which are common in both data frames. (Actually, I could just have to character vectors and would like to print the common elements). I tried this approach: for (elx in x) {for (ely in y) {if (elx==ely) print(ely)}} x, y : character vectors This prints out the correct result but I am not able to assign the resulting probesets and it also seems quite an inelegant solution. Thank you for your help. Juerg Straubhaar UMass Med School
affy ASSIGN affy ASSIGN • 1.1k views
ADD COMMENT
0
Entering edit mode
@arnemulleraventiscom-466
Last seen 10.3 years ago
> > > I have two data frames with a name column containing affy > probeset ids. I would like to pull out the ids (just the ids) > which are common in both data frames. (Actually, I could just > have to character vectors and would like to print the common > elements). > > I tried this approach: > > for (elx in x) {for (ely in y) {if (elx==ely) print(ely)}} > > x, y : character vectors do intersect(x,y) or better type help(intersect) which gives you the help for set operations in R. regards, Arne > This prints out the correct result but I am not able to > assign the resulting probesets and it also seems quite an > inelegant solution. > > Thank you for your help. > > Juerg Straubhaar > UMass Med School > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://www.stat.math.ethz.ch/mailman/listinfo/bioconductor >
ADD COMMENT
0
Entering edit mode
John Zhang ★ 2.9k
@john-zhang-6
Last seen 10.3 years ago
>I have two data frames with a name column containing affy probeset ids. I would like to pull out the ids (just the ids) which are common in both data frames. (Actually, I could just have to character vectors and would like to print the common elements). > >I tried this approach: > >for (elx in x) {for (ely in y) {if (elx==ely) print(ely)}} > >x, y : character vectors Would this work for you: > d1 <- data.frame(matrix(1:20, ncol = 4)) > d2 <- data.frame(matrix(3:22, ncol = 4)) > tt <- intersect(d1[,1], d2[,1]) > d1[d1[,1] %in% tt,] > >This prints out the correct result but I am not able to assign the resulting probesets and it also seems quite an inelegant solution. > >Thank you for your help. > >Juerg Straubhaar >UMass Med School > >_______________________________________________ >Bioconductor mailing list >Bioconductor@stat.math.ethz.ch >https://www.stat.math.ethz.ch/mailman/listinfo/bioconductor Jianhua Zhang Department of Biostatistics Dana-Farber Cancer Institute 44 Binney Street Boston, MA 02115-6084
ADD COMMENT
0
Entering edit mode
@adaikalavan-ramasamy-675
Last seen 10.3 years ago
See help(match). Note that match returns the _first_ match. AFAIK, the probeset ids are unique within any given cdf file, so this should not be a problem. On Tue, 2004-05-04 at 17:02, Straubhaar, Juerg wrote: > I have two data frames with a name column containing affy probeset ids. I would like to pull out the ids (just the ids) which are common in both data frames. (Actually, I could just have to character vectors and would like to print the common elements). > > I tried this approach: > > for (elx in x) {for (ely in y) {if (elx==ely) print(ely)}} > > x, y : character vectors > > This prints out the correct result but I am not able to assign the resulting probesets and it also seems quite an inelegant solution. > > Thank you for your help. > > Juerg Straubhaar > UMass Med School > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://www.stat.math.ethz.ch/mailman/listinfo/bioconductor --
ADD COMMENT

Login before adding your answer.

Traffic: 447 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6