Andris Jankevics wrote: > 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)))
Why not simply table(Z) ? > > (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"? There is no "1" counted, but 4 "2"s, you have not specified an interval with 1 in it. You were looking for table(cut(Z,seq(0,5,1))) but don't need cut() here at all. > Can I get from vector Z a smal vector Zs 1,2,3,4,5 ? seq(min(Z), max(Z)) Uwe Ligges > > Thanks a lot! > > Andris Jankevics > > ______________________________________________ > [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
