[R] Calculating a daily average
ecvetano at uwaterloo.ca
ecvetano at uwaterloo.ca
Mon Jun 21 16:27:18 CEST 2010
I have a set of data with 12 readings for temperature per day, with
180 days. I want to find the average temperature of each day. I am
able to do this one by one, but with that many days to calculate the
average for, it will get very long. I'm sure there is a faster way to
do this, I just don't know how. What i have so far is:
av1 <- subset(ER9r, Day == 98, select = c (Depth1j:Depth0.75j))
av1 <- mean(av1 [av1>0])
av2 <- subset(ER9r, Day == 99, select = c (Depth1j:Depth0.75j))
av2 <- mean(av2 [av2>0])
av3 <- subset(ER9r, Day == 100, select = c (Depth1j:Depth0.75j))
av3 <- mean(av3 [av3>0])
av4 <- subset(ER9r, Day == 101, select = c (Depth1j:Depth0.75j))
av4 <- mean(av4 [av4>0])
av5 <- subset(ER9r, Day == 102, select = c (Depth1j:Depth0.75j))
av5 <- mean(av5 [av5>0])
Depth<- c("SML")
Day<- c(98, 99, 100, 101, 102)
Average<- c(av1, av2, av3, av4, av5)
chlsummaryER9 <- data.frame (Depth, Day, Average)
chlsummaryER9
Any ideas on how to do this in less steps?
Thanks,
Emilija
More information about the R-help
mailing list