[R] annual maximum value

CJ Rubio cjrubio at kongju.ac.kr
Tue Feb 17 07:35:37 CET 2009


thank you very much for your reply.

i studied the code you gave me and tried to make adjustments to fit the
requirements that i need, thank you again.. i used the following codes:

> m <- read.table("D:/documents/5 stations/01014000.csv", sep =",")
> z <- zoo(m[,4],as.Date(as.character(DF[,3]), "%m/%d/%Y"))
> x <- aggregate(z, cut(time(z),"y"), max)

i got the maximum values right using coredata(), my question now is, how can
i call for the complete date (yyyy-mm-dd)  and the year (yyyy) when the
maximum observation for that year was observed? 




CJ Rubio wrote:
> 
>  hi everyone!
> 
> hope you can help me here.
> 
> i am a new R user. what i am trying to do is to find the maximum annual
> discharge from a daily record. i have a data.frame which includes date and
> the discharge. somewhat like this..
> 
> 10/1/1989       2410
> 10/2/1989       2460
> 10/3/1989       2890
> ...
> ...
> ...
> 12/31/2005     5730
> 
> i have been browsing through the archives and fount out about the
> aggregate function and the zoo package. here's one of the codes i've tried
> 
> DF <- read.table(data[i], sep =",")  ##i have several stations to
> assimilate
> Date <- as.Date(as.character(DF[,3]), "%m/%d/%Y") #the date is at the 3rd
> column, obviously
> library(zoo)
> z <- aggregate(zoo(DF[,4]), cut(Date, "y"), max)
> max.discharge <- coredata(z)
> date <- time(z)
> 
> the result should somehow look like this 
> 11/21/1926      32600
>  4/24/1927       66500
> ...
> ...
> ..
> 4/26/2005       111000
> 
> thanks for your time reading my questions,, any suggestions will be truly
> appreciated...
>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/annual-maximum-value-tp22049205p22051398.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list