0

I have a vector of playoff dates here

nflplayoffs <- c('2016-01-09','2016-01-09','2016-01-10','2016-01-10','2016-01-16',)

I am trying to add in a numeric column to my data.table based on those dates using the below line

trx$nflplayoffs <- as.numeric(trx$date==nflplayoffs)

What am I doing wrong here?

1 Answers1

2

We can use %in% instead of == when there are multiple elements

as.integer(trx$date %in% nflplayoffs)
akrun
  • 874,273
  • 37
  • 540
  • 662