Transform + classify · Week 07

Data Transformation + Data Types

Finish transforming rows and columns in R, practice with two classworks, then distinguish data types through page 10 of Lecture 6.

Oct 5–9Lectures 5–6 + Classworks 6–7
ImportantFrom transformation to data types
  1. Review Lecture 5 from page 29, Apply the same conditions to flights, then continue with arrange(), distinct(), select(), and rename().
  2. Complete Classwork 6 (transforming rows) and Classwork 7 (transforming columns).
  3. Begin Lecture 6: Data Types, Databases, and Keys on Wednesday, October 7, covering the data-types section through page 10, Numbers do not always measure quantities.

Classwork 8 and the databases section will continue in Week 8.

Homework 2 is due October 9 at 11:59 PM. Data visualization will begin after the October 19 midterm.

Tentative midterm coverage: Lectures 1–6, through data types, databases, keys, and left_join(). Lecture 7 is excluded from this tentative scope.

Focus

  • Sorting rows and finding unique observations
  • Selecting and renaming columns
  • Data types: nominal, ordinal, interval, and ratio

Prepare

  • Reopen your Lecture 5 R script and review filter()
  • Have Classworks 6 and 7 ready in Posit Cloud
  • Open Lecture 6 for Wednesday and finish Homework 2 by Friday

Practice

  • Transform flight data with filter(), arrange(), and distinct()
  • Select and rename variables in NYC payroll data
  • Distinguish numeric measurements from numeric category labels

Learning targets

  • Sort rows with arrange() and change the sorting direction with desc().
  • Keep unique rows or combinations of values with distinct().
  • Keep or remove columns with select() and change their names with rename().
  • Combine transformation steps in a pipe and check that the result answers the question.
  • Distinguish nominal, ordinal, interval, and ratio data using a variable’s meaning.
  • Explain why numeric codes do not always represent measurable quantities.
Tip

Check the result after each transformation: Did you keep the intended rows, sort them in the intended direction, and retain the columns needed for the question?

Core pattern

flights |>
  filter(month == 1, !is.na(dep_delay)) |>
  arrange(desc(dep_delay)) |>
  select(origin, dest, dep_delay)

Lecture slides

TipLecture slide shortcuts

Click inside the slide preview, then use:

  • the visible ←/→ controls to page through the slides;
  • your mouse wheel or trackpad to keep scrolling the weekly page;
  • M to open the menu;
  • F to enter fullscreen;
  • E to enter or exit PDF export mode;
  • Ctrl + Shift + F to search within the slides;
  • Esc to exit the menu or fullscreen; and
  • T to switch between dark and light mode.
Lecture 5 · Data Transformation · review from page 29View slides in new tab
Lecture 6 · Data Types · through page 10View slides in new tab

This week’s materials

Further material

Lecture 7 · ETL, Big Data, and Data Infrastructure. Its teaching date will be announced separately.

Back to top