[R] Indexing vector with repeated values

From: Andris Jankevics <andza_at_osi.lv>
Date: Fri 26 May 2006 - 17:36:32 EST


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



R-help@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 Received on Fri May 26 17:45:55 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 26 May 2006 - 18:10:26 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.