Skip to content
Prev 36706 / 63424 Next

cdplot() with 'POSIXct' x

On Thu, 13 May 2010, Sebastian P. Luque wrote:

            
I don't think we should special case "POSIXct". The general question would 
be whether we allow "x" variables that can be coerced to numeric. The 
approach would be:
   - Omit all checking of the original "x".
   - Compute
       xorig <- x
       x <- as.numeric(xorig)
     and then proceed as before except for one change.
   - For drawing the axis use
       Axis(xorig, side = 1)
     rather than axis(1).

This would work for POSIXct, Date, and other classes of the same type, 
e.g., yearmon in package "zoo". Also, we could easily write time series 
methods for cdplot() and spineplot() in package "zoo".

The downside is that there is no more checking of the "x" argument and 
weird things could happen without a useful error message when users 
specify awkward x arguments.

I played around with modified versions of cdplot() and also spineplot() 
(where the new labeling is a bit more involved but based on the same 
principles) and could supply code/docs for both.

So the question is whether the more flexible code with reduced checking is 
suitable/acceptable for base R or not.

Best,
Z