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

statquant3 statquant at outlook.com
Thu Jan 7 21:58:03 CET 2016


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.


More information about the datatable-help mailing list