babynames assignment

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 == 1995, sex == "F") |> 
  mutate(percent = round(prop * 100, 1)) |> 
 mutate(rank = row_number()) |> 
  select(year, sex, name, percent, rank) |> 
  filter (name == "Taylor") %>% 
  gt() |> 
  tab_header(title = "My name rank the year I was born")
My name rank the year I was born
year sex name percent rank
1995 F Taylor 1.1 6

My named ranked 6th most popular the year I was born

babynames |>
  filter(year == 1995) |>     
  filter(sex == "F") |>       
  select(name, n) |>          
  wordcloud2(size = .5)   

Here is a word cloud of all the names for girls the year I was born. It looks like Jessica was the most popular.

babynames %>% 
   filter(name == "Taylor", sex == "F") |>      
  mutate(percent = round(prop * 100, 1)) |>     
  ggplot(aes(x = year, y = percent)) +           
  geom_line(color = "blue")                     

This graphs shows that my name gained popularity around 1985, peaked in popularity around 1994, and has reduced in popularity since.

babynames %>% 
  filter (name == "Taylor") %>% 
  slice_max(prop, n=10) %>% 
  mutate(percent = round(prop * 100, 1)) |>    
  mutate(rank = row_number()) |>
  select(year, sex, name, percent, rank) |> 
  gt() %>% 
 tab_header(title = "My name ranked by the years it was most popular")
My name ranked by the years it was most popular
year sex name percent rank
1993 F Taylor 1.1 1
1994 F Taylor 1.1 2
1995 F Taylor 1.1 3
1997 F Taylor 1.0 4
1996 F Taylor 1.0 5
1998 F Taylor 1.0 6
1999 F Taylor 0.9 7
2000 F Taylor 0.8 8
1992 F Taylor 0.7 9
2001 F Taylor 0.7 10

My name was most popular in 1993.

babynames |>
  filter(name == "Taylor" | name == "Alexandria", sex == "F") |>  
  mutate(percent = round(prop * 100, 1)) |>  
  ggplot(aes(x = year, y = percent, color = name)) +
  geom_line()

My name seems to be far more common than the name Alexandria. as you can see it peaks in popularity around the same time mine did, but at a much lower magnitude.

babynames |>
  filter(name == "Moana" | name == "Siri") |> 
  filter(sex == "F") |> 
  filter( year > 2000) %>% 
  ggplot(aes(x = year, y = n, color = name)) +
  geom_line()

You can see the popularity of the name Moana peaked quite suddenly around the time the movie was released.

For the name Siri, it looks like it gained popularity from 2000 and stay popular until about 2012 and then steadily declined in popularity after that.