Re: [R] Calculate aggregate differences

2007-11-01 Thread Andrew Robinson
Hi Cristian, yes, indeed. What I'm not sure about is how doing this by groups will give you a different result, if the object is already sorted according to the group structure. As you are working with differences, each group 'loses' an observation, which will be the observation that is calculat

Re: [R] Calculate aggregate differences

2007-11-01 Thread crmontes
Thanks Andrew, but what you gave me can actually be done simpler like my_agg$vol.diff <- diff(my_agg$Vol) or my_agg$vol.diff <-c(NA, diff(my_agg$Vol)) # for a list with the same #length as the aggregated mean list However, what I need is to be able to h

Re: [R] Calculate aggregate differences

2007-11-01 Thread Andrew Robinson
Hi Cristian, instead of aggregate, how about something like: n <- dim(my_agg)[1] my_agg$vol.diff <- my_agg$Vol - c(NA, my_agg$Vol[1:(n-1)] my_agg <- my.agg[my.agg$Age > min(my.agg$Age),] (assumes same minimum age for all treatments) (not checked) Cheers, Andrew On Thu, Nov 01, 2007 at 12:0

[R] Calculate aggregate differences

2007-11-01 Thread crmontes
Hi everyone I am trying to summarize a table with yield estimates of a forest plantation. For that I have four blocks and four treatments measured over a period of 10 years (every year). In each plot trees are measured (diameters and heights). With aggregate function I can calculate the average