Owen, Jason wrote:
Hello,
Suppose I simulate 20 observations from the Poisson distribution
with lambda = 4. I can summarize these values using table() and
then feed that to barplot() for a graph.
Problem: if there are empty categories (e.g. 0) or empty categories
within the range of the data
Hello,
Suppose I simulate 20 observations from the Poisson distribution
with lambda = 4. I can summarize these values using table() and
then feed that to barplot() for a graph.
Problem: if there are empty categories (e.g. 0) or empty categories
within the range of the data (e.g. observations
Hi
tabulate() approximates your desired functionality:
tabulate(c(1,1,1,4,4,4,8,8))
[1] 3 0 0 3 0 0 0 2
(although this works with integer-valued vectors only; it excludes zero
so you might be better to use tabulate(x+1) to catch this)
HTH
Robin
On 19 Apr 2006, at 14:21, Owen, Jason
On Wed, 2006-04-19 at 09:21 -0400, Owen, Jason wrote:
Hello,
Suppose I simulate 20 observations from the Poisson distribution
with lambda = 4. I can summarize these values using table() and
then feed that to barplot() for a graph.
Problem: if there are empty categories (e.g. 0) or empty
One can use the fact that converting a zoo object to a
ts object fills in the holes with NAs.
First create some test data, x, and create the table, tab.
Then create a zoo object and convert that to a ts object.
Now barplot the ts values using the times as names.
set.seed(1)
x - rpois(20, 4) #
Le 19.04.2006 15:21, Owen, Jason a écrit :
Hello,
Suppose I simulate 20 observations from the Poisson distribution
with lambda = 4. I can summarize these values using table() and
then feed that to barplot() for a graph.
Problem: if there are empty categories (e.g. 0) or empty categories