Book Image

Mastering Data analysis with R

By : Gergely Daróczi
Book Image

Mastering Data analysis with R

By: Gergely Daróczi

Overview of this book

Table of Contents (19 chapters)
Mastering Data Analysis with R
Credits
www.PacktPub.com
Preface

The evolution of the reshape packages


As mentioned before, reshape2 was a complete rewrite of the reshape package, based on around 5 years of experience in using and developing the latter. This update also included some trade-offs, as the original reshape tasks were split among multiple packages. Thus, reshape2 now offers a lot less compared to the kind of magic features that were supported by reshape. Just check, for example reshape::cast; especially the margins and add.missing argument!

But as it turns out, even reshape2 offers a lot more than simply melting and casting data frames. The birth of the tidyr package was inspired by this fact: to have a package in the Hadleyverse that supports easy data cleaning and transformation between the long and wide table formats. In tidyr parlance, these operations are called gather and spread.

Just to give a quick example of this new syntax, let's re-implement the previous examples:

> library(tidyr)
> str(gather(hflights[, c('Month', 'ActualElapsedTime...