Kathie wrote on 10/13/2011 06:33:59 AM:
> 
> Dear R users,
> 
> I'd like to count the number of integers in a vector y.
> 
> Here is an example.
> 
> y <- c(0,1,1,3,3,3,5,5,6)
> 
> In fact, I know how to count the number of specific number in y.
> 
> sum(y==0) -> 1
> sum(y==1) -> 2
> sum(y==2) -> 0
> sum(y==3) -> 3
> sum(y==4) -> 0
> sum(y==5) -> 2
> sum(y==6) -> 1
> 
> 
> However, in one computation I want to get this vector [1,2,0,3,0,2,1]. 
> 
> Thank you in advance.
> 
> Kathie


tabulate(factor(as.integer(y), levels=0L:6L))

Jean
	[[alternative HTML version deleted]]

