<p dir="ltr">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 :)<br>
</p>
<div class="gmail_quote">On Nov 10, 2013 1:39 PM, "G See" <<a href="mailto:gsee000@gmail.com">gsee000@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I have a list of data.tables and I am trying to extract a subset from<br>
each of them. I can achieve what I want with this:<br>
<br>
> L <- list(data.table(BOD), data.table(BOD))<br>
> lapply(L, function(x) x[Time==3L])<br>
[[1]]<br>
Time demand<br>
1: 3 19<br>
<br>
[[2]]<br>
Time demand<br>
1: 3 19<br>
<br>
However, I'd rather not type have to create an anonymous function. I<br>
tried the below, but `[.data.frame` is being dispatched.<br>
<br>
> lapply(L, "[", Time==3L)<br>
Error in `[.data.frame`(x, i) : object 'Time' not found<br>
<br>
Even if I am explicit, `[.data.table` does not get dispatched:<br>
<br>
> lapply(L, data.table:::`[.data.table`, Time==3L)<br>
Error in `[.data.frame`(x, i) : object 'Time' not found<br>
<br>
I'm guessing this is due to where evaluation takes place. Is there an<br>
alternate syntax I should use?<br>
<br>
Thanks,<br>
Garrett<br>
_______________________________________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br>
</blockquote></div>