[R-SIG-Finance] Quantmod / xts problem " Error in `[.xts`(x, xsubset) : subscript out of bounds"

Jeff Ryan jeff.a.ryan at gmail.com
Mon Oct 25 22:34:48 CEST 2010


Hi Immanuel,

The extra col/colname is messing something up in chartSeries.  There
is a new version of chartSeries in quantmod (has been for a while)
called chart_Series.  Mostly same behavior, eventually it will be
almost identical to the old version.

The new version is faster, and more extensible.  Also is much nicer to
look at.  And an added bonus is that it also works out of the box on
your example.

Actually both of these do - the former a workaround to get your code
to work with the original chartSeries functionality.

chartSeries(intradayData[1:15,1:5])

chart_Series(intradayData[1:15])

HTH
Jeff


On Mon, Oct 25, 2010 at 1:08 PM, Immanuel <mane.desk at googlemail.com> wrote:
> Hey Ryan,
>
> thanks for looking into it.
>
> regards,
> Immanuel
>
> ------------------
> library(quantmod)
> library(chron)
> library(zoo)
>
>
> f <- function(x) chron(paste(x[,1]), paste(x[,2], "00", sep = ":"),
>            format = c(dates = "d.m.y", times = "h:m:s"))
>
>
> z <- read.zoo("FDAX_10_min.csv", index = 1:2, header = TRUE, sep =
> ";",FUN = f)
>
> intradayData <- xts(z, order.by = as.POSIXct(time(z)),unique=FALSE)
>
> chartSeries(intradayData[1:15])
> ---------------------------------
> data file:
> ------------------------------
> Date;Time;Open;Close;High;Low;Volume;
> 10.05.10;08:00;5854.5;5911;5925;5850;2066;
> 10.05.10;08:10;5910.5;5895;5911;5887.5;1055;
> 10.05.10;08:20;5895;5892;5901;5884;913;
> 10.05.10;08:30;5890;5903;5904.5;5888.5;630;
> 10.05.10;08:40;5903;5906.5;5925;5901;418;
> 10.05.10;08:50;5906;5896;5910;5894.5;569;
> 10.05.10;09:00;5896.5;5892;5901.5;5869.5;786;
> 10.05.10;09:10;5892.5;5908.5;5909.5;5885;493;
> 10.05.10;09:20;5908;5915;5916.5;5900;743;
> 10.05.10;09:30;5914;5936;5937;5904.5;740;
> 10.05.10;09:40;5937.5;5953.5;5964.5;5933.5;757;
> 10.05.10;09:50;5953;5942.5;5960;5942;420;
> 10.05.10;10:00;5942.5;5934.5;5947;5933.5;279;
> 10.05.10;10:10;5934;5944.5;5949.5;5926.5;366;
> 10.05.10;10:20;5945;5953.5;5956;5938;261;
> 10.05.10;10:30;5953;5938.5;5955;5933;96;
> 10.05.10;10:40;5939;5943;5945.5;5929.5;145;
> 10.05.10;10:50;5942.5;5972.5;5990;5942.5;248;
> 10.05.10;11:00;5972.5;5964;5981.5;5963.5;184;
> ----------------------------------
> On 10/25/2010 08:02 PM, Jeff Ryan wrote:
>> Immanuel,
>>
>> Not entirely sure what is wrong, but you need to provide reproducible
>> code for me to do anything more than hazard a guess.
>>
>> That said, my guess is that something regarding the # of obs you are
>> plotting or the column ordering is the issue.  I have tried to
>> replicate both, and don't seem to see an error on my end, so I'll wait
>> for your code that can be run by me that replicates your error.
>>
>> Best,
>> Jeff
>>
>> On Mon, Oct 25, 2010 at 12:56 PM, Immanuel <mane.desk at googlemail.com> wrote:
>>
>>> Hello all,
>>>
>>> I got some problems while plotting OHLC intraday data
>>> using chartSeries(), ploting of chartSeries(Cl(..) ) works through.
>>>
>>> Who knows whats going on?
>>> best regards,
>>> Immanuel
>>>
>>> -------------------
>>>
>>>> class(intradayData)
>>>>
>>> [1] "xts" "zoo"
>>>
>>>> intradayData[1:5]
>>>>
>>>                      Open  Close   High    Low Volume  X
>>> 2010-05-10 10:00:00 5854.5 5911.0 5925.0 5850.0   2066 NA
>>> 2010-05-10 10:10:00 5910.5 5895.0 5911.0 5887.5   1055 NA
>>> 2010-05-10 10:20:00 5895.0 5892.0 5901.0 5884.0    913 NA
>>> 2010-05-10 10:30:00 5890.0 5903.0 5904.5 5888.5    630 NA
>>> 2010-05-10 10:40:00 5903.0 5906.5 5925.0 5901.0    418 NA
>>>
>>>> chartSeries(intradayData[1:15])
>>>>
>>> Error in `[.xts`(x, xsubset) : subscript out of bounds
>>>
>>> _______________________________________________
>>> R-SIG-Finance at stat.math.ethz.ch mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>>> -- Subscriber-posting only. If you want to post, subscribe first.
>>> -- Also note that this is not the r-help list where general R questions should go.
>>>
>>>
>>
>>
>>
>
>



-- 
Jeffrey Ryan
jeff.a.ryan at gmail.com



More information about the R-SIG-Finance mailing list