Take the following generic data
A <- c(5,7,11,10,23,30,24,6)
B <- c(1,2,3,1,2,3,1,2)
C <- data.frame(A,B)
and the following intervals
library(intervals)
interval1 <- Intervals(
  matrix(
    c(
      5, 15,
      15, 25,
      25, 35,
      35, 100
    ),
    ncol = 2, byrow = TRUE
  ),
  closed = c( TRUE, FALSE ),
  type = "Z"
)
rownames(interval1) <- c("A","B","C", "D")
interval2 <- Intervals(
  matrix(
    c(
      0, 10,
      12, 20,
      22, 30,
      30, 100
    ),
    ncol = 2, byrow = TRUE
  ),
  closed = c( TRUE, FALSE ),
  type = "Z"
)
rownames(interval2) <- c("P","Q","R", "S")
Now I want to create the following output table

So where the A value overlap the two invervals, I want to 'copy' all the data to a line below.
We also introduce data$X which is the interval1 value and data$y which is the interval2 value.
Where data does not fit within any of the interval, I want to remove it from the data.frame
I am not sure if the break() function would be better used to create the intervals or if the dplyr function can be used to make the reoccuring data rows
 
    