Was attempting to check intervals within a dataframe for work to determine if they were within a list of intervals. However, the results would fail on my work computer, and my personal computer.
Does not appear to render without throwing the following error
Error in int %within% lst :
No %within% method with signature a = Interval, b = list
library(lubridate)
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] TRUE
int2 %within% int
#> [1] TRUE
ymd("1999-01-01") %within% int # FALSE
#> [1] FALSE
## recycling (carefully note the difference between using a vector of
## intervals and list of intervals for the second argument)
dates <- ymd(c("2014-12-20", "2014-12-30", "2015-01-01", "2015-01-03"))
blackout_vector <- c(interval(ymd("2014-12-30"), ymd("2014-12-31")),
interval(ymd("2014-12-30"), ymd("2015-01-03")))
dates %within% blackout_vector
#> [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"))
lst <- list(
interval(ymd("2014-12-30"), ymd("2014-12-31")),
interval(ymd("2014-12-30"), ymd("2015-01-03"))
)
dates %within% lst
#> [1] FALSE TRUE TRUE TRUE
## interval within a list of intervals
int <- interval(
ymd("2014-12-20", "2014-12-30"),
ymd("2015-01-01", "2015-01-03")
)
int %within% lst
attached below is my sessioninfo in case that helps. Also, same error was thrown on my work computer as well which is a windows
Was attempting to check intervals within a dataframe for work to determine if they were within a list of intervals. However, the results would fail on my work computer, and my personal computer.
The reprex below was taken from the lubridate website... https://lubridate.tidyverse.org/reference/within-interval.html
The final example... int %within% lst
Does not appear to render without throwing the following error Error in int %within% lst : No %within% method with signature a = Interval, b = list
attached below is my sessioninfo in case that helps. Also, same error was thrown on my work computer as well which is a windows