Lesson 9: Manipulating Data and Repetitive Tasks

Overview Section

Frequently we find that our data is not quite in the form we want it to be. Maybe we need just the means and SEs of some treatments, or we want to calculate a summary variable froms several others. One of the strengths of R is the ease with which data can be manipulated. In fact, I sometimes refer to this chapter as "things I used to do in Excel but are easier in R". Here we'll introduce several useful tools for manipulating data, using Chapter 9 of Essential R.


Upon completion of this lesson, you should be able to:

  • Extract summary statistics for subsets or groups of data defined by factors
  • Change factor levels
  • Calculate new variables from existing variables
  • Stack and unstack data
  • Merge two data frames

Data and R Code Files Section

The R code file and data files for this lesson can be found on the Essential R - Notes on learning R page.