6  Wrangling data

Before creating a figure or a table (see next chapter), data often needs to be manipulated to create variables that are suitable for display. When doing data-intensive work, you will spend most of your time wrangling data. That is, transform, summarise, and describe variables and their relationships. In this chapter, we will introduce R functions that are useful for data wrangling.

6.1 To pipe or not to pipe?

In the previous chapter we used the ggplot function to initialize

6.2 dplyr and tidyr

6.2.1 Selecting variables

6.2.2 Creating and transforming variables

6.2.3 Filter, select and order rows

6.2.4 Combining data sets

6.2.4.1 Join data sets

6.2.4.2 Bind data sets

6.2.5 Summarising variables

6.2.6 Wide- and long-format data