[R] From daily series to monthly and viceversa

Gabor Grothendieck ggrothendieck at gmail.com
Wed Apr 15 22:17:22 CEST 2009


Try this:

> Lines <- "31/12/1993      1,12509
+ 03/01/1994      1,12509
+ 04/01/1994      1,12558
+ 05/01/1994      1,1258
+ 06/01/1994      1,12596
+ 07/01/1994      1,12753
+ 10/01/1994      1,1273
+ 11/01/1994      1,12416
+ 12/01/1994      1,1275"
> library(zoo)
> z <- read.zoo(textConnection(Lines), format = "%d/%m/%Y", dec = ",")
> zm <- aggregate(z, as.yearmon, tail, 1); zm
Warning message:
closing unused connection 3 (Lines)
Dec 1993 Jan 1994
 1.12509  1.12750

and read ?read.zoo, ?aggregate.zoo and the three zoo vignettes
vignette(package = "zoo") # lists their names
vignette("zoo") # displays first one

On Wed, Apr 15, 2009 at 2:26 PM, manta <mantino84 at libero.it> wrote:
>
> I have the following daily exchange rate series  (from january 1st 1996 to
> december 31st 2008) and I want to obtain them monthly series from it. I've
> read about the 'zoo' library but I'm not getting it how to do it. These are
> the data (left column day-month-year, right column the index)
>
> 31/12/1993      1,12509
> 03/01/1994      1,12509
> 04/01/1994      1,12558
> 05/01/1994      1,1258
> 06/01/1994      1,12596
> 07/01/1994      1,12753
> 10/01/1994      1,1273
> 11/01/1994      1,12416
> 12/01/1994      1,1275
>
> Also, I have monthly CPI data and I want to interpolate using the reference
> CPI formula in order to obtain the daily series. The time window is the same
> (January 1996, December 2008).
> Thanks in advance for your help.
>
> --
> View this message in context: http://www.nabble.com/From-daily-series-to-monthly-and-viceversa-tp23064454p23064454.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.
>




More information about the R-help mailing list