[R] counting numbers without replicates in a vector

Jonathan Baron baron at psych.upenn.edu
Thu Dec 16 22:55:18 CET 2004

On 12/16/04 13:40, Jun Ding wrote:
 I am just wondering if there is an easy way to count
 in a numeric vector how many numbers don't have
 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?

Take a look at unique()

Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
R search page: http://finzi.psych.upenn.edu/

More information about the R-help mailing list