[R] Question about plotting discontinuous data

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Fri Sep 9 21:39:27 CEST 2005


On Fri, 9 Sep 2005, Larsen Chung wrote:

> Hi, I have a simple question that I just cannot figure out. I
> have 2 corresponding columns of data, one column (X-axis) for
> time (formatted thus: 8:30:01am = 830.1, 12:30:05pm = 1230.5,
> and one column (Y-axis) for values.

R comes with support for various time formats, use them! Look at
particular at "chron" and "POSIXct". In addition, you might want to define
a time series object which might make plotting (and other operations) even
easier. Look in particular at the "zoo" package which supports both time
formats above.
Z

> When I attempt to plot the data using something like
> plot(inputdata[,1],inputdata[,2],type="l");
> I get breaks in the plot (since the time essentially jumps
> from 8:59:59am = 859.59 to 9:00:00am = 900.0).
>
> Essentially, I get the plot shape I want if I just plot the
> 'values' column using plot(inputdata[,2],type="l");
> however, then I don't get the corresponding 'time' labels. Is
> there a way I can plot these two columns together without the
> 'breaks'?
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list