HI Santosh,

The simplest way I can think of is (after you import the data) to do:
tapply(Zvo$V2, YEAR, sum)

The question is how to get "YEAR".

You could do that if you know how to play with date objects.
Another option is to do something like:

YEAR <- as.data.frame(strsplit(Zvo$V2, "-"))[1,]

For example:
as.data.frame(strsplit(c( "1995-04-01" ,    "1995-04-02"), "-"))[1,]

I am sure others can think of better ways.

Tal



----------------Contact
Details:-------------------------------------------------------
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
----------------------------------------------------------------------------------------------




On Wed, Mar 17, 2010 at 8:20 AM, <santosh.ar...@csiro.au> wrote:

>
> Hello there
>
> I have a DAILY data set (as shown below) with Date and
>  Streamflow from April 1995 to Aug 2006.  I want a yearly sum
> the streamflow value (for each year - first and last
> incomplete year).
>
> Does anyone know how to do this in R?
>
> I have tried everything I could think of, e.g. imported the
> streamflow data as time series using:
>
> flowdata <- ts(ZVo[,2],start = c(1995,4,1), frequency = 7) #
> perhaps frequency = 365 is the better one and tried to
> aggregate using aggregate() without success
>
> >ZVo
>             V1      V2
>  1  1995-04-01 0.002766309
>  2  1995-04-02 0.002402973
>  3  1995-04-03 0.002254335
>  4  1995-04-04 0.002221305
>  5  1995-04-05 0.002180017
>  6  1995-04-06 0.002031379
>  7  1995-04-07 0.001957060
>  8  1995-04-08 0.001940545
>  9  1995-04-09 0.001924030
>  10 1995-04-10 0.001783650
>  .
>  .
>  .
>  4156 2006-08-16 0.02861272
>  4157 2006-08-17 0.03652353
>  4158 2006-08-18 0.05372419
>  4159 2006-08-19 0.05630058
>  4160 2006-08-20 0.06274154
>  4161 2006-08-21 0.06981833
>
>  Many thanks
>
>  Santosh
>
> ______________________________________________
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to