[R] Time on x-axis

Gabor Grothendieck ggrothendieck at gmail.com
Mon Feb 20 17:59:17 CET 2006


Try this:

# test data
tt <- c("23:05:02", "23:10:02", "23:15:03", "23:20:03", "23:25:03",
"23:30:03", "23:35:03", "23:40:03", "23:45:04", "23:50:04", "23:55:03",
"23:55:03")
x <- c(0.575764, 0.738379, 0.567414, 0.663436, 0.599834, 0.679571,
0.88141, 0.868848, 0.969271, 0.878968, 0.990972, 0.990972)

library(zoo)
library(chron)
z <- zoo(x, times(tt))
plot(z)

Read the R Help Desk article in R News 4/1 about dates and times
and also read the chron article in its references.

Also read the zoo vignette which you can access like this:

library(zoo)
vignette("zoo")

and also read ?axis in case you want to customize the axes.


On 2/20/06, Sangeetha Swaminathan <sangi at itc.utk.edu> wrote:
> Hello,
>
>   I just started using the GNU R. I am having trouble plotting my data. I am
> tryin to plot the following data:
>
> TIMESTAMP    LOGIN-TIME
> (hh:mm:ss)          (s)
>
> 23:55:03       0.990972
> 23:55:03       0.990972
> 23:50:04       0.878968
> 23:45:04       0.969271
> 23:40:03       0.868848
> 23:35:03        0.88141
> 23:30:03       0.679571
> 23:25:03       0.599834
> 23:20:03       0.663436
> 23:15:03       0.567414
> 23:10:02       0.738379
> 23:05:02       0.575764
>
> with TIMESTAMP on the x-axis. The plot() function assumes the x-axis as the
> total number of events, and plots the desired graph. But I want the TIMESTAMP
> on the x-axis. If I try to change the x-axis, the y-axis gets modified too,
> and all I get is just a "dot" as a plot.
> Can someone tell me how I can make R plot my graph, with TIMESTAMP as my
> x-axis and LOGIN_TIME as my y-axis?
>
> Thank you.
>
> Sangeetha
>
> -- Sangeetha Swaminathan
> Graduate Assistant
> Innovative Technology Center (ITC)
> 2444 Dunford Hall
> The University of Tennessee
> Knoxville, TN 37996
> Phone [O]:(865) 974-9672
>      [R]:(865) 946-4340
>
> ______________________________________________
> 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