[R-SIG-Finance] align time series correctly

Brian G. Peterson brian at braverock.com
Wed Dec 29 21:27:06 CET 2010


On 12/29/2010 01:53 PM, Lei Jin wrote:
> I am trying to create a data frame that includes data from 3 time series.
> (^IRX, ^VIX, SPY).  I noticed that getSymbols() from yahoo (default) seems
> to retrieve different rows for the 3 time series for the same time window I
> specified.  So, I got an "arguments imply differing number of rows".  My
> simple questions is how do I set # of rows for all 3 time series to be equal
> and aligned by date correctly.

Don't use a data.frame

This is time series data, conveniently returned to you in a time series 
class.

use cbind() on the xts object, and it will all 'just work', putting NA's 
in the missing days, where they belong.

   - Brian


-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list