Skip to content
Prev 7213 / 15274 Next

align time series correctly

Use merge.xts:

require(quantmod)
getSymbols("^IRX;^VIX;SPY", from="1994-01-01")
Data <- merge(IRX,VIX,SPY)

# Note that there will be some NAs
# e.g. 1994-01-17 for IRX
head(Data,20)

# use na.omit to drop them
Data <- na.omit(Data)
nrow(Data)  # 4256

# or use merge's 'all' arg
Data <- merge(IRX,VIX,SPY,all=FALSE)
nrow(Data)  # same as na.omit


Best,
--
Joshua Ulrich ?| ?FOSS Trading: www.fosstrading.com
On Wed, Dec 29, 2010 at 1:53 PM, Lei Jin <leijin56 at gmail.com> wrote: