[R] Aggregating dataset to means/day

2011-03-16 Thread OA Fatnes
Hi, I have a dataset with many observations some days while only one others. I would like to calculate a mean value per day and then do regression analysis on the means. This is what I have: YearDayTimeherring.density 200747 10.36 2.2 200747 11.50

Re: [R] Aggregating dataset to means/day

2011-03-16 Thread Ivan Calandra
Hi, Look at ?aggregate. df - read.table(textConnection(Year Day Time herring.density 2007 47 10.36 2.2 2007 47 11.50 1.1 2007 47 14.24 1.4 2007 66 9.35 2.5), header=TRUE) You could do this: aggregate(herring.density~Year+Day, data=df, FUN=mean) And for the second question: