[R] Creating appropriate time axis for data

Uwe Ligges ligges at statistik.tu-dortmund.de
Mon Dec 12 21:34:19 CET 2011



On 12.12.2011 17:44, Tony Stocker wrote:
> Hello,
>
> I am dealing with data stored in a database as a 'time' object.  I
> export the data from the database to a text file and utilize the
> 'time_to_sec()'

I get

 > time_to_sec
Error: object 'time_to_sec' not found

If it is in a package, please tell us which one you are referring to.

> function of the database to convert the human readable
> time (HH:MM:SS) to seconds so that I can use R to do analysis and
> create charts of the data.  I do not need or use days or dates in the
> data, and the data range is from 07:00:00 to 18:00:00 or 25200-64800
> seconds.  However when I visualize the data in charts I do not want a
> scale that runs from 25200-64800 seconds, but rather in the HH:MM:SS
> format.  Is there a relatively straight-forward and easy to use way to
> do this?

Yes, e.g.:

t <- strptime(c("07:00:00", "18:00:00"), "%H:%M:%S")
y <- rnorm(2)
plot(t, x)

Uwe Ligges



>
> Thanks,
> Tony
>
> ______________________________________________
> 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.



More information about the R-help mailing list