naniar icon indicating copy to clipboard operation
naniar copied to clipboard

shadow-shift / impute-below doesn't handle dates

Open njtierney opened this issue 6 years ago • 2 comments

shadow_shift and therefore impute_below don't handle date objects:

dat_date <- data.frame(date = as.POSIXct(c(111, 
                                           112,
                                           NA,
                                           NA, 
                                           108,
                                           150,
                                           160),
                                         origin = "1970-01-01"))

# as.numeric(dat_date$date)

naniar::shadow_shift(dat_date$date)
#> Error: shadow_shift does not know how to deal with data of class POSIXctPOSIXt please check your input is more than length one

Created on 2018-05-03 by the reprex package (v0.2.0).

This should be able to be fixed by doing some conversion to a numeric object, then sending it back as a whole integer.

njtierney avatar May 03 '18 07:05 njtierney

One thing to keep in mind here is:

  • How do we find out what the original date origin was?
  • Just how many date types are there?

njtierney avatar May 03 '18 07:05 njtierney

It seems reasonable to convert the date to numeric and then coerce back to a date

njtierney avatar Oct 22 '19 02:10 njtierney

There are three extra methods now:

  • POSIXct
  • POSIXlt
  • Date

njtierney avatar May 01 '23 21:05 njtierney