[R] Handling of irregular time series in lineChart

Robert A'gata rhelpacc at gmail.com
Fri Apr 29 02:02:11 CEST 2011


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



More information about the R-help mailing list