I am having trouble using lubridate's pretty_dates
function. It fails in some cases:
library(lubridate)
datetimes <- structure(c(1391640346, 1393856900), class = c("POSIXct", "POSIXt"), tzone = "GMT")
pretty_dates(datetimes, 10)
(I normally wouldn't construct datetimes like this, it's just what dput
gave me.)
This fails with error message:
Error in seq.POSIXt(start, end, paste(binlength, binunits)) : 'to' must be of length 1
Am I doing something wrong here?
I am using lubridate_1.3.3
, the latest version from CRAN.
I believe that looks like a bug. It seems to only be a problem when you have a POSIX object that has a time other than midnight and a prefered units of "days". You can re-create with other values with
pretty_dates(seq.POSIXt(as.POSIXct("2014-02-05 01:00:00 GMT"),
by = "5 day", length.out = 2), 2)
while something like
pretty_dates(seq.POSIXt(as.POSIXct("2014-02-05 01:00:00 GMT"),
by = "9 hours", length.out = 2), 2)
or
pretty_dates(seq.POSIXt(as.POSIXct("2014-02-05 01:00:00 GMT"),
by = "3 months", length.out = 2), 2)
work.
Looks like you can work around it with
pretty_dates(as.Date(datetimes),10)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With