[R] documentation of intersect() on string vector and num vector and on duplicated elements

Peng Yu pengyu.ut at gmail.com
Wed Dec 2 22:33:23 CET 2009


> intersect(c(1,3,2),c('1','3'))
[1] "1" "3"

Apparently, intersect() treats num as string. But this is not
documented in the help. Could somebody add it in the future version of
R?

Also according to the help, the argument should not have duplicated
elements. But I tried the following example, it seems that it doesn't
matter where there are duplicated elements or not. Should the help be
corrected? Or somebody could provide me with an example that make
intersect() fails if there are duplicated elements?

> x=c(3,1,2,1,7)
> y=c(5,1,4,2,3,8,1)
> x
[1] 3 1 2 1 7
> y
[1] 5 1 4 2 3 8 1
> intersect(x,y)
[1] 3 1 2




More information about the R-help mailing list