[R] group values in classes
Rui Barradas
ruipbarradas at sapo.pt
Mon Dec 31 12:33:04 CET 2012
Hello,
Try the following.
classes <- function(x, n){
n*findInterval(x, seq(0, ceiling(max(x)), by = n))
}
c4 <- classes(d, 4)
table(c4)
sum(table(c4))
Happy new year,
Rui Barradas
Em 31-12-2012 10:13, catalin roibu escreveu:
> Dear R users,
> I want to group numerical values in classes with different size and count
> the values for each classes.
>
> My data is in this forma:
> d 15 12,5 30,4 20,5 80,4 100,5 8,2 40,5 33 21 11
> And I want the group them in classes with 4 (5,....etc) cm size like this:
> class d 16 16 32 24 84 104 12 44 36 24 12
> and final to count values for each class:
> class d n 12 2 16 2 24 2 32 1 36 1 44 1
> 84 1 104 1 Total 11
>
> Thank you!
More information about the R-help
mailing list