?duplicated and ?unique might be of interest to you ...

But I think an easier way is:

z<-table(a)
length(z)-sum(z>1)

This gives you the count. 
names(z)[z==1]   gives you the actual values

(The quotes can be removed by explicitly calling print with argument
quote=FALSE)

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
"The business of the statistician is to catalyze the scientific learning
process."  - George E. P. Box
 
 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Jun Ding
> Sent: Thursday, December 16, 2004 1:41 PM
> To: [EMAIL PROTECTED]
> Subject: [R] counting numbers without replicates in a vector
> 
> 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
> 
> 
> =====
> 
> ______________________________________________
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
>

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to