[R] using zoo() to coerce time series to a different reference frame

From: Jonathan Greenberg <greenberg_at_ucdavis.edu>
Date: Tue, 29 Jun 2010 14:58:54 -0700


Folks:

I have two sets of dates, and one set of data:

***

require("chron")
require("zoo")
reference_dates=seq.dates("01/01/92", "12/31/92", by = "months") data_dates=seq.dates("01/15/91", "12/15/93", by = "months") data=1:length(data_dates)

reference_zoo=zoo(order.by=reference_dates) data_zoo=zoo(data,data_dates)

***

What I would like is to have a zoo object that uses the index from reference_dates, but grabs the data for each of the dates (using a spline interpolation) from data_zoo object. I feel like my solution is a bit slow, can someone let me know if there is a quicker way to do this? Thanks:

***

reference_data_zoo_merge=merge(reference_zoo,data_zoo)
reference_data_zoo_data=na.spline(reference_data_zoo_merge)
reference_data_zoo_data=merge(reference_zoo,reference_data_zoo_data,all=FALSE)

***

--j



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. Received on Wed 30 Jun 2010 - 02:18:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 30 Jun 2010 - 05:20:42 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive