[datatable-help] How can I reshape a list of list of data.tables from wide to long

Michael Smith my.r.help at gmail.com
Fri Jan 8 03:05:15 CET 2016


Not sure about a data.table way, but maybe(?) rlist helps:

http://renkun.me/rlist/

M

On 01/08/2016 04:58 AM, statquant3 wrote:
> Following this post on SO:
> http://stackoverflow.com/questions/34643746/how-can-i-reshape-a-list-of-list-from-wide-to-long
> I was wondering if there could be a data.table way to deal with list of list
> of data.tables.
>
> require(data.table)
> l <- list(a1 = list(b=data.table(rnorm(3)), c=data.table(rnorm(3)),
> d=data.table(rnorm(3))),
>            a2 = list(b=data.table(rnorm(3)), c=data.table(rnorm(3)),
> d=data.table(rnorm(3))))
>
> The idea is to go from a N-named list of P-named list of data.table to a
> P-named list of N-named list of data.table (a pure transpose)
>
> +a1---b         +b ---a1
>        ---c             ---a2
>        ---d         +c---a1
> +a2---b    to       ---a2
>        ---c         +d---a1
>        ---d             ---a2
>
> Is there a data.table idiomatic way ?
> Can we make sure the data.tables are not copied ?
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-can-I-reshape-a-list-of-list-of-data-tables-from-wide-to-long-tp4716248.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