%in%does not recognize the shape of the characters of your dates. Consider:
> as.Date("2014-12-31") == "2014-12-31"
[1] TRUE
> as.Date("2014-12-31") %in% "2014-12-31"
[1] FALSE
You need to use:
data2[as.character(data2$as_of_date) %in% c("2014-12-31"),]
Although it is obvious that in this case it ==works fine, since you are matching only one value.
source
share