Re: [R] [R-SIG-Finance] Handling of irregular time series in lineChart

From: Brian G. Peterson <brian_at_braverock.com>
Date: Thu, 28 Apr 2011 23:17:19 -0500

chartSeries and its cousins plot each period as one observation. all observations have equal time. It 'takes care of' irregular data by assuming that the rate of information is equal to the number of observations, which is a perfectly correct intuition and useful for many things. If you want instead to force a regular series, then you may do that instead.

You could create bars, or use a different plotting mechanism.

Often, I will create regular bars (1 minute or even 1 second is sufficient) from the raw price data, and then use some addTA overplotting to plot items of interest.

Regards,

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

On Thu, 2011-04-28 at 20:02 -0400, Robert A'gata wrote:

> Hi,
>
> I realized that when I have irregular series to feed into lineChart,
> the interval of each point in the chart does not seem to take care of
> irregular time interval I specified in my input xts time series. But
> rather, lineChart seems to take each point as equal spaced time
> series. For example, I have the following code:
>
> library(quantmod)
> options(digits.sec=3)
>
> t0 <- as.POSIXct("2010-04-20 09:30:00.000");
> tvec1 <- runif(1000,0,1000);
> tvec1 <- sort(tvec1);
> tvec1 <- t0+tvec1;
>
> t0 <- as.POSIXct("2010-04-20 12:30:00.000");
> tvec2 <- runif(1000,0,1000);
> tvec2 <- sort(tvec2);
> tvec2 <- t0+tvec2;
>
> tvec <- c(tvec1,tvec2);
> data <- cumsum(rnorm(length(tvec)));
>
> tseries <- xts(data,tvec);
>
> lineChart(tseries);
>
> There are two clusters of data points around 9:30AM and 12:30PM.
> However, when lineChart displays result, it is quite clear that all
> points are set to be equally spaced in time. I'm wondering if I
> miss-specified any parameters or not. Any advice would be much
> appreciated. Thank you in advance.
>
> Robert
______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Received on Fri 29 Apr 2011 - 04:21:37 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Apr 2011 - 04:30:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive