Data Visualization

Tidy Data Structure

Overview

Teaching: 5 min
Exercises: 5 min
Questions
  • What is tidy data structure?

  • How do I use tidyr to restructure messy data?

Objectives
  • To understand the importance of tidy data structure

  • To tidy our data in preparation for the final figure

Tidy data structure rules:

  1. Order doesn’t matter
  2. No duplicate rows
  3. Every cell contains one value
  4. One column per type of information
  5. No redundant information

Restructure tables with messy data.

Table Restructure

Important tidyr functions:

Gapminder data time series is stored cross-tabulated.

tidyr Fill-in Challenge

Fill in the missing pieces of the following code to generate a tidy data table.

dplyr Review Fill-in Challenge

Fill in the missing pieces of the following code to filter data for 2007.

Key Points