[R] mean of runoff for several years

Peter Alspach Peter.Alspach at plantandfood.co.nz
Wed Mar 23 22:17:13 CET 2011


Tena koe Dominique

?tapply
?aggregate

For example,

dayMn <- tapply(yourData$runoff, yourData[,c('year','month','day')], mean, na.rm=TRUE)
yearMed <- tapply(dayMn$runoff, dayMn$year, median, na.rm=TRUE)
with(yearMed, plot(year, runoff))

I have not tested the above and since I can never remember exact syntax or output I would not be surprised if the above needed tweaking.

HTH ....

Peter Alspach


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of dominique
> Sent: Thursday, 24 March 2011 9:14 a.m.
> To: r-help at r-project.org
> Subject: [R] mean of runoff for several years
> 
> Hello everyone
> I have a dataframe with 4 colums (year, month, day, runoff) for 1993-
> 2009.
> Now I like to calculate the average runoff for each day. Finally I like
> to
> plot the median runoff for all this years.
> I tried with some loops, but it didn't work. Do you have any Tips for
> my
> problem?
> Any help is greatly appreciated! Thank you very much.
> Dominique
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/mean-of-
> runoff-for-several-years-tp3400541p3400541.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.

The contents of this e-mail are confidential and may be subject to legal privilege.
 If you are not the intended recipient you must not use, disseminate, distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received this
 e-mail in error, please notify the sender and delete all material pertaining to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.



More information about the R-help mailing list