Baby names

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(gt)
library(wordcloud2)
library(babynames)
babynames |>                             
  filter(year == 1998, sex == "F") |>    
  mutate(rank = row_number()) |>         
  mutate(percent = round(prop * 100, 1)) |> 
  filter(name == "Brittanee") |> 
  gt() |>
 tab_header(title = "Popularity of Brittanee in 1998")
Popularity of Brittanee in 1998
year sex name n prop rank percent
1998 F Brittanee 29 1.496e-05 3932 0

My name was not popular at all, which I can attribute to how uniqely my name is spelled. “Brittney, while still not super popular, ranks 143rd at .01%. The overall rank of my name the year I was born is 3932nd.

babynames |>
  filter(year == 1998) |>     # use only one year
  filter(sex == "F") |>       # use only one sex
  slice_max(prop, n=100) |>   # use the top 100 names
  select(name, n) |>          # select the two relevant variables: the name and how often it occurs
  wordcloud2(size = .5)                 # generate the word cloud

This name cloud shows that in 1998 the most popular name for girls Emily.

babynames |>                                    # start with the data
  filter(name == "Brittanee", sex == "F", year > 1990) |>      # choose the name and sex
  mutate(percent = round(prop * 100, 1)) |>     # create a new variable called percent
  ggplot(aes(x = year, y = percent)) +           # put year on the x-axis and prop (proportion) on y
  geom_line(color = "red")                      # make it a line graph and give the line a color

As mentioned earlier, the spelling of my name is so uncommon that my name shows as having 0% popularity over time.

babynames |>
  filter( name == "Brittanee", sex == "F") |> 
  mutate(percent = prop * 100) |> 
  slice_max(prop, n = 1) |> 
  select(year, sex, name, percent) |>
  gt() |>
  tab_header(title = "Year my name was most popular")
Year my name was most popular
year sex name percent
1989 F Brittanee 0.003615

While the popularity was still small, the spelling of my name was most popular in 1989.

babynames |>
  filter(name == "Brittanee" | name == "Lauri" | name == "Martha") |> 
  filter(sex == "F") |> 
  ggplot(aes(x = year, y = n, color = name)) +
  geom_line()

My mom, Lauri, and I are in the same boat when it comes to the uniqeness of how are names are spelled. The popularity of her name is higher than mine by quite a bit, but it is still relatively uncommon. I did notice that both my mother’s and grandmother’s, Martha, names spiked in popularity around the years they were born.

babynames |>
  filter(name == "James" | name == "Michael" | name == "Justin") |> 
  filter(sex == "M") |> 
  ggplot(aes(x = year, y = n, color = name)) +
  geom_line()

One of the three famous people I used were James Dean, who’s name became popular close to the 50s, which was around the same time he became a popular actor. The second was Michael Jordan, who’s name was popular around his birth year, but not necesarily around his time in the sports world. The final celebrity was Justin Beiber, and similar to Michael, his name was popular around his birth year, but was on a decline around the time he became famous in the late 2000s.