r - Is it possible to to find the indexes of blacklisted dates in a sample vector of dates? -


i have tricky problem in r can't seem solve without resorting loop.

i start vector of timedates:

library(timedate) dates <- timedate(c("2014-01-01","2008-01-02","2008-01-03","2008-01-04")) 

i find indexes of dates in preset blacklist:

dateblacklist <- timedate(c("2008-01-02","2008-01-03")) 

the result like:

indexesofblacklisteddates <- c(2,3) 

an ugly solution:

indexesofblacklisteddates <- which(timedate:::as.character.timedate(dates) %in% timedate:::as.character.timedate(dateblacklist)) 

another, not ugly, solution (similar @agstudy's answer)

which(as.character(dates) %in% as.character(dateblacklist)) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -