1 Introduction

One of an archaeologist’s most common challenges is struggling with an uncooperative dataset. Sometimes you might have no-oone to blame but yourself, and other times you may be working with existing (published/inherited/“legacy”) data. They might be causing trouble for all sorts of reasons: for example, because they are full of typographical errors, because recording conventions were inconsistent, because they are formatted in a way that R finds inconvenient, or because the units of analysis in which you’re interested differ from those of the initial collector of the data.

Because this is such a common problem, data cleaning and data wrangling are fantastically useful skills. The former comprises everything from making column names consistent so that they’re easily manipulable, to removing empty rows, to standardizing classifications; the latter commonly involves renaming, recoding, summarizing, and reshaping data.

What you’ll find here are the tools you need to get started with data cleaning and manipulation - concepts, plus an introduction to the very useful (and often irritating) dplyr package. We’ll cover:

  • harvesting data (from importing .csvs to reading MSExcel files and GoogleSheets to scraping .pdfs)
  • naming, renaming, and recoding
  • summarizing and reshaping (wide to long data [and back again?])