[Rd] matplot.Date & matplot.POSIXct

Abby Spurdle @purd|e@@ @end|ng |rom gm@||@com
Tue Jan 28 09:09:45 CET 2020

> > Maybe I'm missing something really obvious here, but I was unable to
> > create a matrix out of POSIXct object(s).
> > Perhaps that deserves a separate discussion...?
>    Can you provide an example?

#date and time objects
x = Sys.Date () + 1:16
y = as.POSIXct (x)

str (matrix (x, 4, 4) )
str (matrix (y, 4, 4) )

Creating a matrix from a Date or POSIXct object, results in a numeric
matrix, not a date/time matrix.

I think that date/time matrices could be useful.
It's possible that this has been discussed before.
But if not, it may be good to discuss it.

And returning to your original post...

I re-read the documentation for the matplot function.
And I feel that it's ambiguous.

The description says:
"Plot the columns of one matrix against the columns of another."
i.e. The matplot function is for *matrices*.

However, then it says:
"x,y vectors or matrices of data for plotting. The number of rows should match."

I'm guessing the current intention is that standard vectors (without a
dim attribute) would be coerce-ible to single-column matrices,
implying that using this function with date and time objects, is
contrary to the way it's currently designed to work.


After reading your examples and re-reading the documentation, your
main suggestion that matplot should support Date and POSIXct objects,
is still *probably* a good one. I note that function is not generic,
and modifications to it would not necessarily be trivial.

More information about the R-devel mailing list