could please tell me how add single second datetimes ended __:59?
i.e. this:
datetime rain_mm 1 2012-12-01 00:00:00 1.0 2 2012-12-01 00:06:00 0.0 3 2012-12-01 00:11:59 0.0 4 2012-12-01 00:17:59 0.0 5 2012-12-01 00:24:00 0.2 6 2012-12-01 00:30:00 0.0 7 2012-12-01 00:36:00 1.0 8 2012-12-01 00:42:00 0.0 9 2012-12-01 00:48:00 0.8 10 2012-12-01 00:53:59 0.2
to:
datetime rain_mm 1 2012-12-01 00:00:00 1.0 2 2012-12-01 00:06:00 0.0 3 2012-12-01 00:12:00 0.0 4 2012-12-01 00:18:00 0.0 5 2012-12-01 00:24:00 0.2 6 2012-12-01 00:30:00 0.0 7 2012-12-01 00:36:00 1.0 8 2012-12-01 00:42:00 0.0 9 2012-12-01 00:48:00 0.8 10 2012-12-01 00:54:00 0.2
any please? thank in advance
you can check as.integer(format(x, "%s") == "59")
when converted integer become either 1
or 0
can conveniently add x
since posixct
measure of seconds (typically 1970-01-01:00:00:00 or, in cases, arbitrary origin).
x = structure(c(1354342319, 1354343040), class = c("posixct", "posixt"), tzone = "") x #[1] "2012-12-01 00:11:59 cst" "2012-12-01 00:24:00 cst" x + as.integer(format(x, "%s") == "59") #[1] "2012-12-01 00:12:00 cst" "2012-12-01 00:24:00 cst"
Comments
Post a Comment