[R] how to sum multiple data entries for the same sampling event?

2012-01-30 Thread karengrace84
I'm having trouble with some catch per unit effort data (CPUE, fisheries data). Some of the samples were retained and some unretained, and they are entered as 2 separate entries for the same sampling event (Date and time). I want to calculate the total CPUE (so sum the retained and unretained

Re: [R] how to sum multiple data entries for the same sampling event?

2012-01-30 Thread R. Michael Weylandt
Perhaps something like # Untested library(plyr) ddply(DATA, Date, function(d) sum(d$lmb.cpue)) For example, on some fake data DATA - data.frame(class = rep(letters[1:5], each = 2), type = rep(c(good, bad), 5), value = rnorm(10)) ddply(DATA, class, function(d) sum(d$value)) If you want to send