15. Reshaping Data in the Tidyverse

Chapter 14 covered numerous ways to reshape data such as binding rows and columns, joins, and converting between wide and long data formats. All the described functions from base R and packages such as plyr, data.table and reshape2 are still great options, but the newer packages dplyr and tidyr are designed to work with pipes and may be easier to use for some people. In some cases, these packages will see speed improvements but not always. These, and other packages written mainly by Hadley Wickham, make up the Tidyverse.

15.1 Binding Rows and Columns

The dplyr analogs to rbind and cbind are bind_rows and bind_cols, respectively. These functions do not behave exactly like their base R counterparts; they only ...

Get R for Everyone: Advanced Analytics and Graphics, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.