Re: [R] Zero counts in an aggregate function

2011-05-17 Thread noellejm
On Mon, May 16, 2011 at 11:56 PM, Jorge Ivan Velez wrote: Hi Noelle, Try using count2 <- function(x) sum(x == 0) or, for all at once (untested), foo <- function(x) c( alive = sum(x == 1), dead = sum(x == 0)) with(bugs, tapply(SURVIVE, FRUIT, foo)) HTH, Jor

[R] Zero counts in an aggregate function

2011-05-16 Thread noellejm
Dear R-users, I've searched for an answer to my question, but so far haven't been able to find a solution. Its likely a simple issue, but have no idea how to do this. A simplified version my (very large) data set looks like this: > > bugs FRUIT SEED_ID SURVIVE 1 1 A 1 2