Skip to content

merge.xts problem

5 messages · Joshua Ulrich, Nikos Rachmanis

#
Nikos,

Please provide a minimal reproducible example.  For examples of how to
do this, see:
http://stackoverflow.com/q/5963269/271616

Best,
--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com

R/Finance 2013: Applied Finance with R  | www.RinFinance.com


On Tue, Feb 12, 2013 at 11:34 PM, Nikos Rachmanis
<nikos.rachmanis at gmail.com> wrote:
1 day later
#
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")
6 days later
#
Nikos,

Thank you for the reproducible example.  This issue was fixed on
R-Forge as of revision 768.

Best,
--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com

R/Finance 2013: Applied Finance with R  | www.RinFinance.com


On Thu, Feb 14, 2013 at 1:58 PM, Nikos Rachmanis
<nikos.rachmanis at gmail.com> wrote:
#
Hi Joshua,

Thank you for the quick fix:)

Nikos

Sent from my iPhone
On Feb 20, 2013, at 21:58, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote: