Skip to content

ceiling_date doesn't work if NA present #486

@adibender

Description

@adibender

As of version 1.6.0, ceiling_date stopped working if the vector contains NA and unit minute, hour, or day (used to work in 1.5.6)

library(lubridate)
dates <- c("02/27/92", "02/27/92", "01/14/92", "02/28/92", "02/01/92")
times <- c("23:03:20", "22:29:56", "01:03:30", "18:21:03", "16:56:26")
x <- paste(dates, times)
times <- strptime(x, "%m/%d/%y %H:%M:%S")
times[2] <- NA

floor_date(times, unit="day") # works fine 
ceiling_date(times, unit="day") # breaks
Error in `[<-.POSIXlt`(`*tmp*`, not_same, value = c(699231600, NA, 695430000,  : 
  NAs are not allowed in subscripted assignments

These are the offending lines in round.R (if new or new1 contain NA):

not_same <- new1 != new
new1[not_same] <- new1[not_same] + delta

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions