[datatable-help] using lapply to subset mant data.tables

G See gsee000 at gmail.com
Thu Feb 26 18:15:53 CET 2015


You didn't provide the desired output, but I think you're looking for
something like this?

    lapply(DTList, "[", x==1L)
    lapply(DTList, subset, x==1L)

HTH,
Garrett


On Thu, Feb 26, 2015 at 11:02 AM, statquant3 <statquant at outlook.com> wrote:
> say I have 3 data.tables
>
> set.seed(1)
> DT1 = data.table(x=c(1L,1L,2L),y=rnorm(3))
> DT2 = data.table(x=c(1L,2L,2L),y=rnorm(3))
> DT3 = data.table(x=c(2L,2L,1L),y=rnorm(3))
>
> DTList = list(DT1,DT2,DT3)
>
> I'd like to apply the i expression "x==1L" to all 3 DTs
> I tried several approaches with lapply like:
>
> lapply(DTList, FUN=subset, select=quote(x==1L))
> lapply(DTList, FUN=subset, select=x==1L)
>
> None works, is there a smart DT way to do this (my DTs are in a list)
>
> Cheers
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/using-lapply-to-subset-mant-data-tables-tp4703898.html
> Sent from the datatable-help mailing list archive at Nabble.com.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help


More information about the datatable-help mailing list