[R] Indexing vector with repeated values

Andris Jankevics andza at osi.lv
Fri May 26 09:36:32 CEST 2006


Hi all,
I have a vector which contains many repeated values.

>Z <- c(1,2,3,4,5,1,2,3,4,5,1,2,3,5,5,2,3,4,5)

I need to know how many times each number in this vecetor is repeated.
I can use a command like this:

> table (cut(Z,seq(1,5,1)))

(1,2] (2,3] (3,4] (4,5] 
    4     4     3     5 

But how can I find a break points for vector with random values and random 
number sequence intervals? Why result for interval (1,2) is 4, if there is 
only 3 values of "1"?

Can I get from vector Z a smal vector Zs 1,2,3,4,5 ?


Thanks a lot!

Andris Jankevics



More information about the R-help mailing list