I assume you are using the is.holiday
function from the chron
package. I'd recommend against using that package; the date functions in R have improved since it was written and it isn't needed.
If you want to use is.holiday
, you need to provide a list of holidays in the format that chron
is expecting. This isn't easy; see this question How to define holidays for is.holiday() chron package in R from 2016 for a discussion.
But if you're providing the list of holidays, you don't need is.holiday
. Just use %in%
. For example,
holidays <- as.Date(c(NewYears = "2014-01-01", Christmas = "2014-12-25"))
# Add more to the list above...
# Convert your data plus a holiday to POSIXct format:
interv <- as.POSIXct(c("9/1/2014 00:00:25",
"9/1/2014 00:00:28",
"9/1/2014 00:00:40",
"1/1/2014 00:00:00"), format = "%m/%d/%Y %H:%M:%S")
# Extract the date:
dates <- as.Date(interv)
# Test if you've got a holiday:
dates %in% holidays
This gives me
[1] FALSE FALSE FALSE TRUE
at the end.