Re: [R] From daily series to monthly and viceversa

2009-04-18 Thread manta
Thanks so much -- View this message in context: http://www.nabble.com/From-daily-series-to-monthly-and-viceversa-tp23064454p23116875.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.e

Re: [R] From daily series to monthly and viceversa

2009-04-18 Thread Gabor Grothendieck
Try this: library(zoo) # z is CPI. Just use 1, 2, 3, ... for example. z <- zooreg(1:12, as.yearmon("2008-01"), freq = 12) # z2 contains z and lags of z and days.in.month # It has a Date class time index, rather than yearmon. days.in.month <- as.numeric(as.Date(time(z), frac = 1) - as.Date(tim

Re: [R] From daily series to monthly and viceversa

2009-04-18 Thread manta
Well Gabor, this is actually a really good help, thanks so much. There is only one problem, I'm getting what you say, but in the code there are a couple of errors time(z2) <- as.Date(time(zz)) #probably z2 z3 <- na.locf( cbind(zz, zoo(, dd), #dd object not

Re: [R] From daily series to monthly and viceversa

2009-04-17 Thread Gabor Grothendieck
Here is a partial solution: library(zoo) # z is CPI. Just use 1, 2, 3, ... for example. z <- zooreg(1:12, as.yearmon("2008-01"), freq = 12) days.in.month <- as.numeric(as.Date(time(z), frac = 1) - as.Date(time(z)) + 1) z2 <- cbind(z, z1 = lag(z, -1), z2 = lag(z, -2), z3 = lag(z, -3), days.in.mont

Re: [R] From daily series to monthly and viceversa

2009-04-17 Thread manta
any update anybody? I'm really stucked! -- View this message in context: http://www.nabble.com/From-daily-series-to-monthly-and-viceversa-tp23064454p23103052.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing

Re: [R] From daily series to monthly and viceversa

2009-04-16 Thread manta
Ok, I'll try to explain my issue. I have a monthly series (CPI index) and I want to interpolate it using a specific lagged harmonized formula to get the corresponding daily series. The formula is the following CPI^=CPI(t-3)+(d-1)/D*(CPI(t-2)-CPI(t-3)) where CPI^ is the CPI for the day we are ca

Re: [R] From daily series to monthly and viceversa

2009-04-15 Thread Gabor Grothendieck
You can remove missing values with: zm <- aggregate(cambio, as.yearmon, mean, na.rm = TRUE) Its not clear what your second question is asking. If you want the series to have a Date class rather than yearmon class with the 1st of the month then: zd <- zm time(zd) <- as.Date(time(zm)) or zd <-

Re: [R] From daily series to monthly and viceversa

2009-04-15 Thread manta
Ok, using mcambio <- aggregate(cambio, as.yearmon, mean) works perfectly!! Should I worry about the missing values or not anyway? And then I go to the following question. From monthly data to daily using a specific formula? -- View this message in context: http://www.nabble.com/From-daily-seri

Re: [R] From daily series to monthly and viceversa

2009-04-15 Thread manta
Ok, thanks for the quick reply. I was not able to use the first command, but reading the quick reference helped me. Here's what I did. > cambio<-read.zoo("C:\\Users\\Manta\\Desktop\\useuro.txt", format = > "%d/%m/%Y", dec = ",",header=T) > cambio #this is what i get 1996-01-01 1996-01-02 1996-01-

Re: [R] From daily series to monthly and viceversa

2009-04-15 Thread Gabor Grothendieck
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(

[R] From daily series to monthly and viceversa

2009-04-15 Thread manta
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/199