Combining multiple datasets, whether by stacking or joining, is commonly necessary as is changing the shape of data. The plyr
and reshape2
packages offer good functions for accomplishing this in addition to base tools such as rbind
, cbind
, and merge
.
Manipulating data takes a great deal of effort before serious analysis can begin. In this chapter, I consider when the data need to be rearranged from column-oriented to row-oriented (or the opposite) and when the data are in multiple, separate sets and need to be combined into one.
There are base functions to accomplish these tasks, but I focus on those in plyr
, reshape2
, and data.table
.
While the tools covered in this chapter still form the backbone of data reshaping, newer packages like tidyr
and dplyr
are starting to supersede them.
No Comments, Be The First!