Chapter 4. Restructuring Data
We already covered the most basic methods for restructuring data in the Chapter 3, Filtering and Summarizing Data, but of course, there are several other, more complex tasks that we will master in the forthcoming pages.
Just to give a quick example on how diversified tools are needed for getting the data in a form that can be used for real data analysis: Hadley Wickham, one of the best known R developers and users, spent one third of his PhD thesis on reshaping data. As he says, "it is unavoidable before doing any exploratory data analysis or visualization."
So now, besides the previous examples of restructuring data, such as the counting of elements in each group, we will focus on some more advanced features, as listed next:
- Transposing matrices
- Splitting, applying, and joining data
- Computing margins of tables
- Merging data frames
- Casting and melting data