[R] counting numbers without replicates in a vector

Spencer Graves spencer.graves at pdf.com
Thu Dec 16 22:53:32 CET 2004


      Have you considered something like the following: 

 > a
[1] 1 1 2 2 3 4 5
 > sum(table(a)==1)
[1] 3     

      hope this helps.  spencer graves

Jun Ding wrote:

>Hi,
>I am just wondering if there is an easy way to count
>in a numeric vector how many numbers don't have
>replicates. 
>For example, 
>a=c(1,1,2,2,3,4,5), how can I know there are three
>numbers (3, 4 and 5) without replicates?
>
>Thank you!
>
>Jun
>
>
>=====
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>

-- 
Spencer Graves, PhD, Senior Development Engineer
O:  (408)938-4420;  mobile:  (408)655-4567




More information about the R-help mailing list