To get quicker answers, it's helpful and often required to have a reproducible example, such as:
set.seed(123)
ndates=5
Dataset = data.frame(
M_start.x = as.Date(round(runif(ndates)*31), origin = "2019-01-01"),
M_end.x = as.Date(round(runif(ndates)*31), origin = "2019-02-01"),
M_start.y = as.Date(round(runif(ndates)*31), origin = "2019-01-15"),
M_end.y = as.Date(round(runif(ndates)*31), origin = "2019-02-15")
)
Dataset
> M_start.x M_end.x M_start.y M_end.y
> 1 2019-01-10 2019-02-02 2019-02-14 2019-03-15
> 2 2019-01-25 2019-02-17 2019-01-29 2019-02-23
> 3 2019-01-14 2019-03-01 2019-02-05 2019-02-16
> 4 2019-01-28 2019-02-18 2019-02-02 2019-02-25
> 5 2019-01-30 2019-02-15 2019-01-18 2019-03-17
subset(Dataset, (M_start.x <= M_start.y & M_start.y >= M_end.x) |
(M_start.x <= M_end.y) & (M_end.y >= M_end.x))
> M_start.x M_end.x M_start.y M_end.y
> 1 2019-01-10 2019-02-02 2019-02-14 2019-03-15
> 2 2019-01-25 2019-02-17 2019-01-29 2019-02-23
> 4 2019-01-28 2019-02-18 2019-02-02 2019-02-25
> 5 2019-01-30 2019-02-15 2019-01-18 2019-03-17
The key is that you can't do comparisons on both sides of a variable in R such as
M_start.x <= M_start.y >= M_end.x
This would work in SAS (which I'm guessing is where you are coming from?)
Instead, use something like this:
(M_start.x <= M_start.y & M_start.y >= M_end.x)
being sure to surround by parentheses to make a single compound expression.