[R] graphics useRaster check_irregular definition for date or posix
p@u| @end|ng |rom @t@t@@uck|@nd@@c@nz
Wed Apr 14 04:37:48 CEST 2021
I doubt it is intended (to deliberately exclude "difftime" objects).
Can you please supply a full image() example (with 'x' and/or 'y' as
Dates and a 'z') ? So that I can see what ...
image(x, y, z, useRaster=FALSE)
... looks like, so I can see what you want ...
image(x, y, z, useRaster=TRUE)
... to look like.
I also wonder whether switching to ...
... might be better than switching to ...
It produces the same result for "difftime" objects, and may have a
better chance of working better with other objects (although I confess
that not having thought of using a "difftime" for 'x' I am also failing
to think of further possibilities for 'x').
On 14/04/21 3:11 am, cdanek using posteo.de wrote:
> The function `check_irregular()` defined within
> `graphics::image.default()` checks if the `useRaster` argument for
> `graphics::image()` can be true or must be false.
> According to this function, the following example vector is irregular:
> time <- seq(as.Date("2020-1-1"), as.Date("2020-12-31"), l=12)
> check_irregular(time, time)
> # TRUE
> In my view, this is not correct.
> In this case, the `all.equal`-call does not evaluate to true due to the
> special class of `dx` (or `dy`). If I slightly rewrite the function as
> my_check_irregular <- function (x, y)
> dx <- as.numeric(diff(x))
> dy <- as.numeric(diff(y))
> (length(dx) && !isTRUE(all.equal(dx, rep(dx, length(dx))))) ||
> (length(dy) && !isTRUE(all.equal(dy, rep(dy, length(dy)))))
> the correct answer is obtained (i.e. that the input vector is not
> irregular based on the rational behind `all.equal`):
> my_check_irregular(time, time)
> # FALSE
> The same applies to POSIX* objects. I was wondering if this is intended
> or not?
> Thanks a lot for any answer,
> [[alternative HTML version deleted]]
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
64 9 3737599 x85392
paul using stat.auckland.ac.nz
More information about the R-help