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

Remko Duursma remkoduursma at gmail.com
Tue Dec 1 04:48:04 CET 2009


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


r

-------------------------------------------------
Remko Duursma
Post-Doctoral Fellow

Centre for Plants and the Environment
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

Mobile: +61 (0)422 096908
www.remkoduursma.com



On Tue, Dec 1, 2009 at 2:42 PM, Peng Yu <pengyu.ut at gmail.com> wrote:
> 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.
>
> ______________________________________________
> 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