Hello,
Maybe functions "xts", "endpoints" and
"period.apply" of the "xts"
package might help you.
Regards,
Pascal
On Fri, Feb 28, 2014 at 1:32 AM, Yang Yang <simonyangyang at gmail.com>
wrote:> Hi
>
> Currently I am working on a river discharge data analysis. I have the daily
> discharge record from 1935 to now. I want to extract the annual maximum
> discharge for each hydrolocial year (*start from 01/11 to next year
31/10*).
> However, I found that the hydroTSM package can only deal with the natural
> year. I tried to use the "zoo" package, but I found it's
difficult to
> compute, as each year have different days. Does anyone have some idea?
> Thanks.
>
> the data looks like:
>
> 01-11-1935 66302-11-1935 59603-11-1935 45004-11-1935 38105-11-1935
> 35406-11-1935 312
>
> my code:
>
> mydata<-read.table("discharge")
> colnames(mydata) <- c("date","discharge")
>
> library(zoo)
> z<-zooreg(mydata[,2],start=as.Date("1935-11-1"))
>
> mydta$date <- as.POSIXct(dat$date)
>
> q.month<-daily2monthly(z,FUN=max,na.rm = TRUE,date.fmt >
"%Y-%m-%d",out.fmt="numeric")
> q.month.plain=coredata(q.month)
>
> z.month<-zooreg(q.month.plain,start=1,frequency=12)
>
> Thanks very much.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
--
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan