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@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
[EMAIL PROTECTED]
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!
______________________________________________
R-help@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.