Skip to content
Prev 11298 / 15274 Next

merge.xts problem

Hi Joshua,

I did some additional research and found that the command below, which 
tries to shift the index by 3 days, creates a problem and does not allow 
to the 2 datasets to be combined.
#shift the index
index(weekly)<-index(weekly)+3

This used to work in the previous version but not anymore.

Attached you will find the datasets and r code.

Nikos
On 2/13/2013 6:55 AM, Joshua Ulrich wrote:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 000.SPX.csv
Type: application/vnd.ms-excel
Size: 26759 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20130214/7078c280/attachment.xlb>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 001.S&P_Commit.csv
Type: application/vnd.ms-excel
Size: 5201 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20130214/7078c280/attachment-0001.xlb>
-------------- next part --------------
####################################################################################################################
### Libraries + Settings ###########################################################################################
####################################################################################################################
#Clear memory
rm(list=ls())
#Increase display buffer (only when it is used with display opearations)
options(max.print=5E8)

#Common Libraries
library(xts)

#Read the files 
data01=read.csv("000.SPX.csv", sep=",", header=TRUE)
data02=read.csv("001.S&P_Commit.csv", sep=",", header=TRUE)

#Create the xts using the constructor
daily<-xts(data01[,-1],as.Date(data01[,1],"%m/%d/%Y"))

#replace NA with zeros(0) in Commit
data02<-replace(data02,is.na(data02),0)

#Create the xts using the constructor
weekly<-xts(data02[,-1],as.Date(data02[,1],"%m/%d/%Y"))

#shift the index
index(weekly)<-index(weekly)+3

#merge the 2 datasets
tradedata<-merge.xts(daily,weekly,join="left")