Skip to content
Prev 31217 / 398506 Next

Posix data in Lattice

A variation of this did the trick.  I had to manually scale the number of
ticks, but it works out well.

Thank you..

-----Original Message-----
From: Renaud Lancelot [mailto:renaud.lancelot at cirad.fr] 
Sent: Friday, April 25, 2003 10:48 AM
To: Shawn Way
Subject: Re: [R] Posix data in Lattice
Shawn Way wrote:
format looks what you need (see below). Here is a start, but I am not 
very easy with as.POSIX**. In particular, I don't know how to convert 
from numeric to POSIX**.

x    <- as.POSIXlt(ISOdate(2002, 4, 25, 12) + seq(0, 3600 * 3, 1800))
y    <- rnorm(length(x$min))
nlab <- as.numeric(as.POSIXct(x))
clab <- format(x, format = "%H:%M")
foo <- data.frame(Y = y, X = nlab)
rm(x, y, nlab, clab)
x    <- as.POSIXlt(ISOdate(2002, 4, 25, 12) + seq(0, 3600 * 3, 1800))
y    <- rnorm(length(x$min))
nlab <- as.numeric(as.POSIXct(x))
clab <- format(x, format = "%H:%M")
foo <- data.frame(y = y, x = nlab)
rm(x, y)
library(lattice)
xyplot(y ~ x, data=foo, scales=list(x = list(at=nlab, labels=clab)))

Best,

Renaud