I think your last attempt's failure is a bug of the internal cedta function, but note that if it did work, it'd be more symbols to type than the anonymous function option :) On Nov 10, 2013 1:39 PM, "G See" <[email protected]> wrote:
> Hi, > > I have a list of data.tables and I am trying to extract a subset from > each of them. I can achieve what I want with this: > > > L <- list(data.table(BOD), data.table(BOD)) > > lapply(L, function(x) x[Time==3L]) > [[1]] > Time demand > 1: 3 19 > > [[2]] > Time demand > 1: 3 19 > > However, I'd rather not type have to create an anonymous function. I > tried the below, but `[.data.frame` is being dispatched. > > > lapply(L, "[", Time==3L) > Error in `[.data.frame`(x, i) : object 'Time' not found > > Even if I am explicit, `[.data.table` does not get dispatched: > > > lapply(L, data.table:::`[.data.table`, Time==3L) > Error in `[.data.frame`(x, i) : object 'Time' not found > > I'm guessing this is due to where evaluation takes place. Is there an > alternate syntax I should use? > > Thanks, > Garrett > _______________________________________________ > datatable-help mailing list > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help >
_______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
