Nothing to do with lubridate
.
Your issue is scoping. You have a column b
in your data.table. data.table
will look first in the data.table
and then up along the search path. It cannot tell you want to look for b
in the parent.frame
So, rename your vector in the parent (global) environment
B <- b
a[date %in% B]
date a b
1: 2001-06-30 -1.89904968 0.9230171
2: 2001-07-07 0.08599561 -0.0440927
3: 2001-07-14 -0.28606686 0.4649957
4: 2001-07-21 0.39191680 0.2907855
5: 2001-07-28 0.18732463 -0.1743267