I have a time series with many millions of points. Each point is of the form (time, value) but where the value is 0 there is no record - ie the data set is sparse. If I plot this using plot(myData) I get a correct plot going from time 0 to time 7x10e7. Given that there are many millions of points (it's not *that* sparse), this looks very busy. But if I attempt to plot this as a line - plot(myData, type="l") - the plot is wrong (it looks like solid semi-sinusoidal curves) and although the x-axis is drawn from 0 to 7x10e7, the plotting stops at about 3x10e7. The same thing is seen if I use plot(myData[[1]], myData[[2]], type="l"). If I use plot(myData[[2]], myData[[1]], type="l") I do get a line (albeit that the orientation seems odd), but again, while the y-axis is drawn between 0 and 7x10e7, the plotting again seems to stop at 3x10e7 or thereabouts. What have I got wrong? How can I get a line (preferably with the standard orientation)? Adrian
Plotting a large time series
2 messages · Adrian Mcmenamin, Jim Lemon
1 day later
Hi Adrian, This is probably taking a long time. I first tried with 7x10^6 times and values and it took several minutes. The following code does what I expected: amdat<-data.frame(time=1:700000,value=rnorm(700000,-4)) amdat$value[amdat$value<0]<-0 sum(amdat$value) [1] 5.07101 plot(amdat$time,amdat$value) plot(amdat$time,amdat$value,type="l") Perhaps convert the time series to two ordinary vectors? Jim
On Sat, Apr 23, 2016 at 9:37 PM, Adrian Mcmenamin <acm538 at york.ac.uk> wrote:
I have a time series with many millions of points.
Each point is of the form (time, value) but where the value is 0 there is
no record - ie the data set is sparse.
If I plot this using plot(myData) I get a correct plot going from time 0 to
time 7x10e7.
Given that there are many millions of points (it's not *that* sparse), this
looks very busy.
But if I attempt to plot this as a line - plot(myData, type="l") - the plot
is wrong (it looks like solid semi-sinusoidal curves) and although the
x-axis is drawn from 0 to 7x10e7, the plotting stops at about 3x10e7.
The same thing is seen if I use plot(myData[[1]], myData[[2]], type="l").
If I use plot(myData[[2]], myData[[1]], type="l") I do get a line (albeit
that the orientation seems odd), but again, while the y-axis is drawn
between 0 and 7x10e7, the plotting again seems to stop at 3x10e7 or
thereabouts.
What have I got wrong? How can I get a line (preferably with the standard
orientation)?
Adrian
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.