Project 2: Approach

Author

Yalda Azamee

Published

November 28, 2026

Introduction

The goal of Project 2 is to practice preparing untidy, wide-format data for analysis using tidyr and dplyr. I selected three independent public datasets that are structurally wide, which means values that should be in one column are spread across many columns. Each dataset will be tidied and analyzed in its own Quarto file.

# Dataset Source Why it is wide
1 NYC population by borough, 1950–2040 NYC Open Data One column per year, plus a separate “share of NYC total” column for each year
2 Global surface temperature by month, 1880–present NASA GISTEMP v4 One row per year and one column per month (Jan … Dec)
3 US state population and components of change, 2020–2024 U.S. Census Bureau Many measures repeated for every year (POPESTIMATE2020, BIRTHS2021, DEATHS2022, …), 75 columns

Planned Approach

I will follow the same steps for each dataset:

  1. Raw data (step 3.1). Download the original file without changing it and save it as a .csv in the data/ folder of my GitHub repository. Each Quarto file will read its data from the raw GitHub URL, so the code runs on any computer.
  2. Describe the structure before tidying. Show the column names, the number of rows, and a sample of the raw data.
  3. Reshape from wide to long with pivot_longer().
  4. Normalize the variable structure. When a column name contains two pieces of information (for example a measure and a year), I will split it into two variables with names_pattern, and use pivot_wider() where needed so that each measure has its own column.
  5. Rename variables to a consistent snake_case style (lowercase with underscores).
  6. Handle missing and inconsistent values and document each decision in the text.
  7. Analyze only the tidy data, with a summary table (labeled columns and units), a ggplot2 chart (title, axis labels, legend), and a short interpretation. All three files will use the same chart style.

Planned analysis for each dataset

  1. NYC population: Which boroughs grew or shrank since 1950, and how did each borough’s share of the city change?
  2. Global temperature: How much has the world warmed since the late 1800s? Compare average temperatures by decade and identify the warmest years.
  3. US state population: Which states grew fastest from 2020 to 2024, and did the growth come from natural change (births minus deaths) or from migration?

Anticipated Data Challenges

NYC population

  • Column names mix two measures: population (1950) and share (1950 - Boro share of NYC total). These must be separated into a year and a measure.
  • Borough names have extra leading spaces.
  • The file includes a “NYC Total” row, which is a sum of the boroughs, not a borough. I will use it to check my data and then remove it.
  • Some years are projections, not actual counts. I will add a variable that marks each value as actual or projected.

Global temperature

  • The file has a title line above the real header, which must be skipped.
  • Missing values are written as *** instead of being blank.
  • Summary columns (annual J-D, D-N, and seasonal DJF, MAM, JJA, SON) are mixed in with the monthly columns. They can be calculated from the months, so I will keep only the 12 monthly columns.
  • The current year is incomplete, so it should not be compared with full years.
  • The values are anomalies (differences from the 1951–1980 average, in °C), not actual temperatures. This needs to be explained clearly.

US state population

  • The file mixes different geographic levels: the whole US, 4 regions, 9 divisions, 50 states, DC, and Puerto Rico. The SUMLEV column identifies the level.
  • Each column name combines a measure and a year, so they must be split.
  • Some measures do not exist for every year (for example, rates start in 2021), which creates missing values after reshaping.
  • Column names are uppercase codes that need to be renamed.

AI Use

Anthropic. (2026). Claude Opus 5.5 [Large language model]. https://claude.ai. Accessed November 28, 2026. Used to help find suitable wide datasets, and understand the assignment.