Assuming your time was an "X" variable, you can use round or trunc .
Try:
round(X, "hour") trunc(X, "hour")
This will still require some work to determine if the values โโwere really rounded or omitted (for round ). So, if you do not want to think about it, you can use the "lubridate" package:
X <- structure(c(1430050590.96162, 1430052390.96162), class = c("POSIXct", "POSIXt")) X # [1] "2015-04-26 17:46:30 IST" "2015-04-26 18:16:30 IST" library(lubridate) ceiling_date(X, "hour") # [1] "2015-04-26 18:00:00 IST" "2015-04-26 19:00:00 IST" floor_date(X, "hour") # [1] "2015-04-26 17:00:00 IST" "2015-04-26 18:00:00 IST"
source share