On Thu, Apr 07, 2011 at 05:37:08AM +0200, fisken wrote:
> 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?
> And what I wanted was
>
> 0 1 2 3 4 5
> 0 1 1 1 0 2
The solution using factos has already been posted. if you are really
interested in integers only you could also use tabulate():
> tabulate(s)
[1] 1 1 1 0 2
Note that this excludes zero, though.
cu
Philipp
--
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
Maximus-von-Imhof-Forum 3
85354 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/
______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.