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:
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
This is what I want:
Year Day herring.density
2007 47 1.57
2007 66 2.25
I would also might like to extract means between time 10-16 (h) so that
Year Day herring.density
2007 47 1.25
Any idea on how to do this?
I have tried
means07<-tapply(herring.density,Day,mean)
Then I get means for every day, but means07 won't fit when plotted against
days, because it is now shorter than Day. I also get a lot of NA values
where there are only 1 observation that day...
Help would be much appreciated!
Cheers,
Ole Andreas
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.