[R] Odp: Is there a function to test if all the elements in a vector are unique

Petr PIKAL petr.pikal at precheza.cz
Tue Dec 1 09:19:39 CET 2009


Hi


r-help-bounces at r-project.org napsal dne 01.12.2009 04:42:31:

> length(unique(c(1,2,2)))==length(c(1,2,2))
> 
> I use the above test to test if all the elements in a vector are
> unique. But I'm wondering if there is a convenient function to do so
> in R library.

maybe
any(duplicated(c(1,2,2)))

Regards
Petr

> 
> ______________________________________________
> 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.




More information about the R-help mailing list