Check whether a
lies within the interval b
, inclusive of the endpoints.
a %within% b
a | An interval or date-time object. |
---|---|
b | Either an interval vector, or a list of intervals. If |
A logical vector.
int <- interval(ymd("2001-01-01"), ymd("2002-01-01")) int2 <- interval(ymd("2001-06-01"), ymd("2002-01-01")) ymd("2001-05-03") %within% int # TRUE#> [1] TRUEint2 %within% int # TRUE#> [1] TRUE#> [1] FALSE## recycling dates <- ymd(c("2014-12-20", "2014-12-30", "2015-01-01", "2015-01-03")) blackouts<- c(interval(ymd("2014-12-30"), ymd("2014-12-31")), interval(ymd("2014-12-30"), ymd("2015-01-03"))) dates %within% blackouts#> [1] FALSE TRUE FALSE TRUE## within ANY of the intervals of a list dates <- ymd(c("2014-12-20", "2014-12-30", "2015-01-01", "2015-01-03")) blackouts<- list(interval(ymd("2014-12-30"), ymd("2014-12-31")), interval(ymd("2014-12-30"), ymd("2015-01-03"))) dates %within% blackouts#> [1] FALSE TRUE TRUE TRUE