Skip to content
Prev 87237 / 398506 Next

subtotal, submean, aggregate

Create another variable that gives the run number and aggregate on
both the habitat and run number removing the run number after
aggregating:

runno <- cumsum(c(TRUE, diff(as.numeric(transect[,2])) !=0))
aggregate(transect[,1], list(obs = transect[,2], runno = runno), sum)[,-2]

This does not give the same as your example but I think there are some
errors in your example output.
On 2/26/06, Patrick Giraudoux <patrick.giraudoux at univ-fcomte.fr> wrote: