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 ______________________________________________ R-help@r-project.org 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.
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:
- [R] Calculating a daily average ecvetano
- Re: [R] Calculating a daily average David Winsemius
- Re: [R] Calculating a daily average Gavin Simpson