Class 7 — Data Wrangling with dplyr

Part II
Fix what you diagnosed last class — chain filter(), mutate(), group_by(), and summarize() into a single pipeline that collapses your own pilot data into a condition-level summary table.
Published

October 20, 2026

PART II · CLASS 7

Last class you read your own pilot data into R and found something messy about it. Today you fix it. Working first on an instructor sample dataset and then on your own HW3 file, you’ll chain filter(), mutate(), group_by(), and summarize() into one readable pipeline that turns trial-level data into a clean, condition-level summary table — the same table HW4 asks you to produce on your own.

Reading due: Data Skills ch. 3; R4DS ch. 3 · Due today:

What you’ll be able to do

  1. Use filter() to keep only the rows that satisfy a logical condition (e.g., excluding practice trials or missing responses), building on the read_csv()/glimpse() fluency from Class 6.
  2. Use mutate() to create or clean up a column (e.g., an accuracy indicator, a standardized participant-ID column) without changing the number of rows.
  3. Use group_by() and summarize() together to collapse trial-level data into a condition-level summary (mean RT, accuracy proportion per condition).
  4. Chain multiple dplyr verbs with the pipe (|> or %>%) into a single readable pipeline.
  5. Sanity-check a summarized result against a partner’s independently-produced summary of a different dataset, building the habit of verifying wrangling output rather than trusting it blindly.
Back to top