ss
2008-May-31 20:10 UTC
[R] How to identify overlapped items from two list and plot them?
Hi list, I have a question on how to identify the overlapped items from two vectors:>x<-c(0,1,2) >y<-c(1,2,2,3)and plot the number of the overlapped as well as non-overlapped in a diagram? Thanks much, Allen [[alternative HTML version deleted]]
Ben Tupper
2008-May-31 21:14 UTC
[R] How to identify overlapped items from two list and plot them?
Hello, On May 31, 2008, at 4:10 PM, ss wrote:> Hi list, > > I have a question on how to identify the overlapped items from two > vectors: > >> x<-c(0,1,2) >> y<-c(1,2,2,3) >You can use the %in% operator to return a logical vector that indicates the overlap. > x<-c(0,1,2) > y<-c(1,2,2,3) > y %in% x [1] TRUE TRUE TRUE FALSE> and plot the number of the overlapped as well as non-overlapped in a > diagram? >I am not sure what you mean by plotting the number of overlaps. Do you mean show the overlaps with a special symbol? Or do you want to just show the number? If it is the former, perhaps the following would do? > plot(x,rep(1,length(x)), xlim = c(0,5)) > points(y, rep(1,length(y)), pch = "+") > iy = which(y %in% x) > points(y[iy], rep(1,length(iy)), pch = "+", col = "red") Cheers, Ben Ben> Thanks much, > Allen > > [[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.Ben Tupper PemaquidRiver at tidewater.net I GoodSearch for Ashwood Waldorf School. Raise money for your favorite charity or school just by searching the Internet with GoodSearch - www.goodsearch.com - powered by Yahoo!
Philipp Pagel
2008-May-31 21:46 UTC
[R] How to identify overlapped items from two list and plot them?
> I have a question on how to identify the overlapped items from two vectors: > > >x<-c(0,1,2) > >y<-c(1,2,2,3)intersect(x,y)> and plot the number of the overlapped as well as non-overlapped in a > diagram?Are you talking about a Venn diagram? There is a vennDiagram function in the limma package and possibly in others. You will find some hints here: http://research.stowers-institute.org/efg/R/Math/VennDiagram.htm cu Philipp -- Dr. Philipp Pagel Lehrstuhl f?r Genomorientierte Bioinformatik Technische Universit?t M?nchen Wissenschaftszentrum Weihenstephan 85350 Freising, Germany and Institut f?r Bioinformatik und Systembiologie / MIPS Helmholtz Zentrum M?nchen - Deutsches Forschungszentrum f?r Gesundheit und Umwelt Ingolst?dter Landstrasse 1 85764 Neuherberg, Germany http://mips.gsf.de/staff/pagel