To calculate the overlap between two date ranges in R, you can use the int_overlaps()
function from the intervals
package. Here is some example code:
main.r277 chars12 lines
This will output the overlapped date range as an Intervals
object:
main.r66 chars4 lines
If you want to do this with data frames using dplyr
, you can use the int_overlap()
function from the intervals
package. Here is a code snippet that demonstrates how to calculate the overlap for each row in a data frame:
main.r560 chars19 lines
This will add a new column, overlap
, to the data frame containing the overlapped date range for each row, as an Intervals
object.
main.r333 chars6 lines
gistlibby LogSnag