[R] counting numbers without replicates in a vector

Marc Schwartz MSchwartz at MedAnalytics.com
Thu Dec 16 23:10:09 CET 2004


On Thu, 2004-12-16 at 13:40 -0800, 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

How about:

> as.vector(which(table(a) == 1))
[1] 3 4 5

HTH,

Marc Schwartz




More information about the R-help mailing list