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

Erik Iverson eiverson at NMDP.ORG
Wed Dec 2 22:48:03 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?
> 

This is more a general coercion feature. For example 1 == "1", see ?Comparison. 

> Also according to the help, the argument should not have duplicated
> elements. 

I think this is just because these functions were written with sets in mind, which would not have duplicated values, thus the word "conceptually".  The duplicated elements are simply discarded. 




More information about the R-help mailing list