What’s in a Name?? (Part 5 Exercises)

What’s in a Name?? (Part 5 Exercises)

Matthew Beckman & Justin Post June 25, 2021


Here, we join an analysis already in progress…


Names to be investigated


We’re investigating the popularity of names in the US each year. Matt has chosen to investigate the names of each person in his immediate family: Matthew, Sarah, Eden, Jack, and Hazel. They’re his favorite people, and also his favorite names! He’s feeling torn about how to include his son Jack in the analysis. Jack’s legal name is “Jon” but he is nearly always called “Jack”–the spelling of “Jon” honors Scandinavian heritage on both sides of the family, and the nickname “Jack” specifically honors his great-grandfather.

Some famous persons by each name of the family include:

This document was last modified 2021-06-25 12:31:45.


Summaries of Name Popularity


# libraries
library(tidyverse)
library(dcData)

# data intake
data("BabyNames", package = "dcData")

BabyNamesSupp <- 
  read_csv("https://jbpost2.github.io/TeachingWithR/datasets/BabyNamesSupp.csv",  
           col_types = cols(sex = col_character()))  

BabyNames2020 <- 
  read_csv("https://jbpost2.github.io/TeachingWithR/datasets/yob2020.txt", 
           col_names = FALSE, col_types = cols(X2 = col_character())) %>%
  rename(name = X1, sex = X2, count = X3) %>%  
  mutate(year = 2020) 

# Combine data sources
BabyNamesFull <- bind_rows(BabyNames, BabyNamesSupp, BabyNames2020)

According to US Social Security data from 1880 through 2020, “Matthew” was the most frequently occurring name in the family.

# vector of names
beckmans <- c("Matthew", "Sarah", "Eden", "Jack", "Hazel")

BabyNamesFull %>%
    filter(name %in% beckmans) %>%                   
    group_by(name) %>%                               
    summarise(total = sum(count, na.rm = TRUE)) %>%  
    arrange(desc(total))
## `summarise()` ungrouping output (override with `.groups` argument)

We also learned that “Eden” was more balanced between the two sexes when compared to the other names in the family.

BabyNamesFull %>%
    filter(name %in% beckmans) %>%
    group_by(name, sex) %>%                          # Task 4.2.3
    summarise(total = sum(count, na.rm = TRUE)) %>%  # Task 4.2.3
    arrange(name)
## `summarise()` regrouping output by 'name' (override with `.groups` argument)

Matt joined Penn State University in 2015, and coincidentally his son Jack was born earlier that year. Interestingly, the name “Jack” was more popular than “Sarah” in 2015, despite the fact that “Sarah” had been far more common when all years had been combined. Perhaps more surprisingly, the name “Hazel” was nearly as common as “Sarah” in that year!

BabyNamesFull %>%
    filter(name %in% beckmans, year == 2015) %>%
    group_by(name) %>%
    summarise(total = sum(count, na.rm = TRUE)) %>% 
    arrange(desc(total))
## `summarise()` ungrouping output (override with `.groups` argument)
BabyNamesFull %>%
    filter(name %in% beckmans, year == 2015) %>%
    group_by(name, sex) %>%
    summarise(total = sum(count, na.rm = TRUE)) %>% 
    arrange(name)
## `summarise()` regrouping output by 'name' (override with `.groups` argument)

Part 5. Graph it


We want to create a graph that highlights the change in popularity among the names you have chosen over the years.