I'm calculating seconds past 1st Jan, 2013 midnight and then taking mean of that and adding it back to 1st Jan, 2013 midnight.
I guess there are packages that can do this from just one command but if you, like me, don't wish to rely too much on packages then this solution should work for you.
library(data.table)
timetable <- data.table(TimeMin = c("2013-05-02 13:45:00",
"2013-05-03 12:30:00",
"2013-05-04 12:30:00",
"2013-05-05 12:30:00",
"2013-05-06 12:30:00",
"2013-05-07 13:15:00")
)
timetable <- timetable[, TimePastMin :=
difftime(
"2013-01-01 00:00:00",
TimeMin,
units = "secs"
)
]
meanTimePastMin <- mean(timetable[, TimePastMin])
meanTimeMin <- strptime("2013-01-01 00:00:00", "%Y-%m-%d %H:%M:%S") - meanTimePastMin
meanTimeMin
# "2013-05-05 00:50:00 IST"