Message-ID: <20110407080206.GA4312@maker>
Date: 2011-04-07T08:02:06Z
From: Philipp Pagel
Subject: force output dimension of table function
In-Reply-To: <BANLkTin1Y_BCSC=V0MDSsquKd1TJu6G7Bg@mail.gmail.com>
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/