midpoint between two POSIXct times
I would like to to take the meridian or midpoint between the stoptime and starttime and then add a new column with the midpoint. It can be rounded to the nearest second. How does one do this in R? Both stoptime and starttime are in POSIXct form. Is there an easier way than dividing difftime in half and then adding to stoptime?
> head(data) bikeid end.station.id start.station.id diff.time stoptime starttime 24 23966 359 318 1505 2015-10-13 07:45:00 2015-10-13 08:10:05 28 23966 502 311 2072 2015-10-20 14:41:11 2015-10-20 15:15:43 58 17110 337 340 3338 2015-10-15 16:00:39 2015-10-15 16:56:17 74 23822 501 527 3478 2015-10-05 15:55:13 2015-10-05 16:53:11 83 16462 426 146 3368 2015-10-01 07:52:06 2015-10-01 08:48:14 89 23121 435 223 1499 2015-10-08 11:58:08 2015-10-08 12:23:07
> dput(head(data))
structure(list(bikeid = c("23966", "23966", "17110", "23822",
"16462", "23121"), end.station.id = c("359", "502", "337", "501",
"426", "435"), start.station.id = c("318", "311", "340", "527",
"146", "223"), diff.time = c(1505, 2072, 3338, 3478, 3368, 1499
), stoptime = structure(c(1444740300, 1445370071, 1444942839,
1444078513, 1443703926, 1444323488), class = c("POSIXct", "POSIXt"
), tzone = "EST"), starttime = structure(c(1444741805, 1445372143,
1444946177, 1444081991, 1443707294, 1444324987), class = c("POSIXct",
"POSIXt"), tzone = "EST")), .Names = c("bikeid", "end.station.id",
"start.station.id", "diff.time", "stoptime", "starttime"), row.names = c(24L, 28L, 58L, 74L, 83L, 89L), class = "data.frame")