I have a data set that looks like this:
9/1/2014 00:00:25
9/1/2014 00:00:28
9/1/2014 00:00:40
There are many more observations...
I want to create a column that indicates if a date is a holiday or not , so i used the is.holiday()
function. This is my code:
final_uber_4$is_holiday <- is.holiday(final_uber_4$interv)
The problem is that it returnes 0 for all the observations although I know for sure there are holidays in my data set.
I assume you are using the
is.holiday
function from thechron
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 thatchron
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,This gives me
at the end.