ylab in plot.POSIXct
Ed Kademan wrote:
I am using R-1.7.0 and have some data which consist of one vector of numbers and a second corresponding vector of dates belonging to the POSIXct class. I would like to plot the numbers against the dates. What is the best way to do this? It almost works to just call `plot.' However if I do this while using the `ylab' parameter I get a warning message: parameter "ylab" couldn't be set in high-level plot() function
In this case, you can ignore that warning message (it's a warning, not an error).
Here is a function that demonstrates the behavior.
ylabProblem <- function() {
x <- ISOdate(2003, 4, 1:10) # POSIXct vector
y <- rnorm(10)
plot(x, y, ylab = 'I am y')
}
It works to invoke the low-level plotting routines by hand as follows:
ylabNoProblem <- function() {
x <- ISOdate(2003, 4, 1:10) # POSIXct vector
y <- rnorm(10)
plot.default(x, y, xaxt = 'n', xlab = '', ylab = 'I am y')
axis.POSIXct(1, x)
}
But I don't like calling methods explicitly like this.
axis.POSIXct() is not a method, because axis() is not a generic function (and hence not able to dispatch for POSIXct objects). Calling axis.POSIXct() explicitly is a not a bad idea in this case. Uwe Ligges