Re: [R] creating empty cells with table()

2006-04-21 Thread Jim Lemon
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

[R] creating empty cells with table()

2006-04-19 Thread Owen, Jason
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

Re: [R] creating empty cells with table()

2006-04-19 Thread Robin Hankin
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

Re: [R] creating empty cells with table()

2006-04-19 Thread Marc Schwartz
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

Re: [R] creating empty cells with table()

2006-04-19 Thread Gabor Grothendieck
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) #

Re: [R] creating empty cells with table()

2006-04-19 Thread Romain Francois
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