[R] force output dimension of table function
fisken
torpedofisken at gmail.com
Thu Apr 7 05:37:08 CEST 2011
I have a small annoying problem.
When I use the 'table' function on a simple vector it counts the
number of occurences.
So depending on the values of my input vector the function returns a
class of type table with different lengths.
Is there an easy way to tell the table function, the values to expect?
That is
#############
> set.seed(0)
> s<-sample(0:5,5,rep=T)
> s
[1] 5 1 2 3 5
> ts<-table(s)
> ts
s
1 2 3 5
1 1 1 2
##############
And what I wanted was
0 1 2 3 4 5
0 1 1 1 0 2
Thanks
More information about the R-help
mailing list