[R] Posix data in Lattice

Deepayan Sarkar deepayan at stat.wisc.edu
Fri Apr 25 18:33:19 CEST 2003


On Friday 25 April 2003 08:21 am, Shawn Way wrote:
> I have a number of plots that I'm trying to do using the lattice package,
> unfortunately, they involve Posix values.
>
> A small sample of the data is as follows:
>
>                    Time   TC.1  <Snipped>
> 1   2003-04-24 13:29:15  26.61
> 2   2003-04-24 13:29:30  26.48
> 3   2003-04-24 13:30:00  26.53
> 4   2003-04-24 13:30:30  27.85
> <Snipped>
>
> where
>
> str(data)
> `data.frame':	415 obs. of  22 variables:
>  $ Time :`POSIXlt', format: chr  "2003-04-24 13:29:15" "2003-04-24
> 13:29:30" "2003-04-24 13:30:00" "2003-04-24 13:30:30" ...
>  $ TC.1 : num   26.6  26.5  26.5  27.9 100.0 ...
> <Snipped>
>
> What I'm trying to do is plot TC.1 vs Time (which I can do easily), but I
> need the xaxis to represent the Time instead of a numeric such as
> 105121000,etc.

Try converting Time to POSIXct and use it normally in a lattice call (maybe 
lattice should do the conversion itself). This should display the times 
properly, however, the formatting definitely needs some improvement.

Let me know if this doesn't solve your problem.

Deepayan



More information about the R-help mailing list