[R-SIG-Finance] Error in `[.xts`(one, trim:length(two), ) : subscript out of bounds

Stephen Choularton @tephen @ending from org@nicfoodm@rket@@com@@u
Tue Jul 10 22:14:45 CEST 2018


Hi

I am getting this error even though I'm pretty sure I am not out of bounds:

Error in `[.xts`(one, trim:length(two), ) : subscript out of bounds
In addition: Warning message:
In trim:length(two) :
   numerical expression has 305 elements: only the first used

I have tried all sorts of things but clearly I am not figuring out what 
is going wrong.

I am developing code to recover prices from IB and test for cointegration.

There are two files attached:

* checkPairFromIB

* metals.csv

It all worked fine until I discovered gold and silver returned data of 
different lengths:  Gold had 320 days of data and silver 305.  The calls 
for data at lines 25 and 26 are identical so I don't know why.  Can 
anyone shed light on this?

I then tried to trim the longer table by disposing of the earlier 15 
lines (see lines 44 to 55 of the code).  This is where the error 
messages came up.  Can anyone point out what I am doing wrong?

Thanks.

Stephen

-- 
----------------------------------------------------------------------------------------------------------------------------------- 

Stephen Choularton PhD, FIoD
0413 545 182


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: checkPairFromIB.R
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20180711/1116296b/attachment.ksh>

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: metals.csv
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20180711/1116296b/attachment-0001.ksh>


More information about the R-SIG-Finance mailing list