Reshaping Data in R

H Wickham

Proceedings of the 4th International Workshop on Directions in Statistical Computing (DSC 2005), pp. 1-7, 2005


Abstract

Restructuring data is a common task in practical data analysis, and it is usually unintuitive and tedious. Data often has multiple levels of grouping (nested treatments, split plot designs, or repeated measurements) and typically requires investigation at multiple levels. For example, from a long term clinical study we may be interested investigating relationships over time, or between times or patients or treatments. Performing these investigations fluently requires the data to be reshaped in different ways. Currently R supplies a reshape function that can perform some of these tasks, but confounds multiple steps in the process and is hard to use. We propose a new conceptual framework for reshaping operations and an R package to “deshape” data frames and then flexibly “reshape” them to meet your needs. This framework also produces contingency tables, cross-tabulations, and summary statistics.

Keywords

RReshapeStatistics