data.table Reshaping, stacking and splitting


The official vignette, "Efficient reshaping using data.tables", is the best introduction to this topic.

Many reshaping tasks require moving between long and wide formats:

  • Wide data is data with each column representing a seperate variable, and rows representing seperate observations
  • Long data is data with the form ID | variable | value, where each row representing a observation-variable pair