Being more used to base::subset, I was surprised when the following didn't work:
x = data.table(a = rep(1:5, 3), b = rep(1:3, each = 5), v = rnorm(15))
dcast(x, a ~ b, value.var = 'v', subset = a > 1)
Error in which(eval(subset, data, parent.frame())) :
argument to 'which' is not logical
That's because dcast.data.table is modelled after reshape2::dcast, where the following is expected:
x = data.table(a = rep(1:5, 3), b = rep(1:3, each = 5), v = rnorm(15))
# works
dcast(x, a ~ b, value.var = 'v', subset = .(a > 1))
Am I missing something? Can't we just drop the .()?
We could also support both -- should be easy to peel off .() if we see it.
Being more used to
base::subset, I was surprised when the following didn't work:That's because
dcast.data.tableis modelled afterreshape2::dcast, where the following is expected:Am I missing something? Can't we just drop the
.()?We could also support both -- should be easy to peel off
.()if we see it.