[R] From daily series to monthly and viceversa

manta mantino84 at libero.it
Sat Apr 18 20:28:18 CEST 2009


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 found
			day.of.month = as.numeric(format(time(zz), "%d"))
))
z3$day.of.month <- as.numeric(format(time(zz2), "%d")) #z2?

And why did you call partial this solution?
Thanks again for you great help
Take care


Gabor Grothendieck wrote:
> 
> 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.month)
> time(z2) <- as.Date(time(zz))
> z3 <- na.locf(
> 		cbind(zz,
> 			zoo(, dd),
> 			day.of.month = as.numeric(format(time(zz), "%d"))
> ))
> z3$day.of.month <- as.numeric(format(time(zz2), "%d"))
> # now each row of z3 has all the data you need so apply(z3, 1,
> your.function)
> 
> 
> On Fri, Apr 17, 2009 at 2:13 PM, manta <mantino84 at libero.it> wrote:
>>
>> 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 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.
>>
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/From-daily-series-to-monthly-and-viceversa-tp23064454p23115847.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list