On Thu, Sep 27, 2012 at 4:03 AM, CALEF ALEJANDRO RODRIGUEZ CUEVAS <alejandro.rodriguez.cue...@gmail.com> wrote: > Hi everybody. > > I use to work with monthly data, however this is my first time working with > weekly data. > > I have 4 data bases with monthly data and 1 with weekly data, so I want to > convert my weekly to monthly data in order to have the same periodicity in > all of them. > > I've read that package xts can help me with this issue, so I have done the > following script: > > *ini_week<-as.Date("2010-09-19") > > final_week<-seq(ini_week, length.out=104, by = "1 week") > > vts<-read.csv("C:/DATA.csv",header = TRUE) > vts<-vts[,2] > > wvts<-xts(vts, order.by=final_week) > mes<-apply.monthly(wvts,sum) > > *A portion of the result is this one: > > [,1] > 2010-09-26 2.9 > 2010-10-31 8.5 > 2010-11-28 5.8 > 2010-12-26 5.5 > 2011-01-30 7.5 > .... > > It seem to be quite well however I have still the question about how does > it work...I mean, for example the last week of September 2010 goes from * > "2010-09-26"* to *"2010-10-03"* with a total number of sales of that week > of 1.5 USD millions...so, how does R assign the portion of those 1.5 USD > millions to the last days of September and the first 2 days of October?
It doesn't. The vector is divided into non-overlapping intervals by the endpoints() function and they are summed separately. Read through ?endpoints Michael > > Thanks a lot in advance. > > Regards. > > [[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. ______________________________________________ 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.