Chapter 6 – Working with Column Structures

In this chapter, we will continue to work on the tidy approach, but this time, instead of working on the structure of the entire dataset, we will work on columns that may not be tidy, either because they contain multiple variables (where there should only be one), or because multiple columns contain the same variable.

For those of you taking Sociology 1205, this chapter covers the data wrangling module for unit 6. You will find the tutorial and exercise scripts in your R Studio Cloud environment.

This will be our last module focused on the tidyr package.

We have already explored the conceptual aspects of the tidy approach in the previous unit’s first video. If you need a refresher, please go back to chapter 5. Otherwise, the tutorial videos below examine how to reshape the structure of columns.

Learning Objectives

In this chapter, we will cover the following topics:

  • splitting columns that contain more than one variable;
  • joining columns that contain the same variable.

The mechanics of splitting and joining columns are not very complicated, so in this case, we will work three examples for each.

Part 1 – Example 1

Part 2 – Example 2

Part 3 – Example 3

Key functions used in this chapter

  • separate()
  • unite()

Before moving on to the next chapter or the exercise (for those of you in Sociology 1205), check your understanding with the quiz below.

License

Icon for the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License

Data Wrangling with R Copyright © 2022 by Christine A Monnier is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License, except where otherwise noted.

Share This Book