Is there an easy way to get the midpoint between two dates in a data frame
? If I have a dataframe that looks like this :
head(x)
instDay remDay exp.time mpy
1 2006-02-02 2006-04-03 60 0.2
2 2006-04-17 2006-08-17 122 0.3
4 2006-08-17 2006-10-23 67 0.4
6 2006-10-23 2007-04-03 162 0.3
8 2007-04-03 2007-05-15 42 0.8
11 2007-05-15 2007-08-01 78 0.3
I would like an additional column that represents the midpoint between
instDay and newDay. For those days where the time difference is an odd
number and the midpoint would not be a specific date, it would be OK to
round up or round down.
I thought about converting both columns to numeric values and taking the
difference, dividing by two with modulus operator, then adding to the
first column and finally converting back to a date. But I'm think there
must be a more simple way.