Have 3.5 years daily data that I want to convert to weekly. Looking for something like SAS's "expand" function, where you can specify the conversion function (sum, average, etc.) and get a new vector out with different sampling frequencies. Anything like that in R ?? Have been looking all over... Thanks, B.D.L. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>Have 3.5 years daily data that I want to convert to weekly. Looking for something > like SAS's "expand" function, where you can specify the conversion function (sum, > average, etc.) and get a new vector out with different sampling frequencies.OK, think I see what to do. The ts class has no calendar/date functions, it assumes a constant delta-t. So I could use "aggregate.ts" on my daily data with a ts having a defined frequency of 364 and knock it down to 52. That would work ok. However, for calendar/date based aggregation to monthly/quarterly/yearly summaries I need to first create the appropriate factor based on a POSIX date vector and then use that in the "by" variable of "aggregate.data.frame" I think ... -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 2 Oct 2002, FWR wrote:> Have 3.5 years daily data that I want to convert to weekly. Looking for > something like SAS's "expand" function, where you can specify the > conversion function (sum, average, etc.) and get a new vector out with > different sampling frequencies. >aggregate(). -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Thanks to Jason Turner and others for their comments. I still have to decide whether the calendar (POSIXt) based week-of-year aggregates, or the constant 7-day aggregates (using aggregate.ts), are more appropriate for what I want to do with these several years of daily data. In my case, the POSIXt based week-of-year calculations end up with a less than 7 day aggregate at the beginning and end of each year, sometimes only one day is used in the aggregation. The week-of-year starts not on 1-Jan but on the first Sunday of January. There are a varying number of weeks in any given year. What I want is to break up each year separately into exactly 52 equal-length intervals and obtain an average property over each interval. Unfortunately, aggregate.ts requires that 52 be evenly divisible into #days/year . It doesn't do interpolations. I might be able to fudge it with the eps parameter ... or just randomly throw out 1 or 2 days per year. Wishlist: that aggregate.ts that could use interpolation methods to change frequencies. Thanks, Bruce L. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._