Skip to content

Data Manipulation

Paige Miller edited this page Jan 9, 2018 · 16 revisions

Incrementally improving your data

Tidy Data:

Hadley Wickham, developer of R packages like reshape, ggplot2, stringr, and probably others, has advocated for scientists to strive for "tidy" data. He says, "Tidy datasets are all alike but every messy dataset is messy in its own way". Here's a link to his paper on Tidy Data and here is a tutorial on data tidying. Tidy data make analysis much friendlier and this is why Drake Lab members might want to make their data Tidy. Key tidy data principles:

  1. Each column is it's own variable e.g., "male_treated" should be split into separate variables for sex and treatment status. Store units in their own variable or in metadata, e.g., "3.4" instead of "3.4kg".
  2. Make each row an observation: Data often come in a wide format, because that facilitated data entry or human inspection. Imagine 1 row per field site and then columns for measurements made at each of several time points. Be prepared to gather such columns into a variable of measurements, plus a new variable for time point.

Which R packages help you make Tidy Data?

  • dplyr -- relevant functions/links
  • tidyr --

Note that you can save intermediate data cleaning steps, or you can clean as you as part of the data management process. Either is fine. See Good Enough Practices for a discussion.

Lab Links

Clone this wiki locally