── 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.1
✔ 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 ==1993, sex =="M") |>mutate(rank =row_number()) %>%mutate(percent =round(prop *100, 1)) |>filter(name =="Paul") |>select(year, sex, name, percent, rank) |>gt() |>tab_header(title ="Popularity of the Name Paul in 1993")
Above is a `wordcloud representing the most popular names from the year 1993.
babynames |>filter(name =="Paul", sex =="M") |>mutate(percent =round(prop *100, 1)) %>%ggplot(aes(x = year, y = percent)) +geom_line(color ="green", size =1)
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
Above is a graph depicting the popularity of the name “paul” over time.
babynames %>%filter(name =="Paul") %>%slice_max(prop, n =20) %>%mutate(rank =row_number()) %>%mutate(percent =round(prop *100, 2)) %>%select(year, percent, rank) |>gt() |>tab_header(title ="Peak Years of Popularity for the Name Paul ")
Peak Years of Popularity for the Name Paul
year
percent
rank
1964
1.33
1
1965
1.32
2
1966
1.30
3
1963
1.29
4
1967
1.28
5
1955
1.28
6
1946
1.28
7
1953
1.27
8
1954
1.27
9
1956
1.25
10
1945
1.24
11
1957
1.23
12
1968
1.23
13
1925
1.23
14
1952
1.23
15
1947
1.23
16
1958
1.22
17
1941
1.21
18
1944
1.20
19
1949
1.20
20
Above is a table displaying the years in which the name “Paul” was at the peak of its popularity.
babynames |>filter(name =="Paul"| name =="Eric", sex =="M") |>mutate(percent =round(prop *100, 1)) %>%ggplot(aes(x = year, y = percent, color = name)) +geom_line( size =1)
Above is a comparison in popularity between the names “Paul” and “Eric” over time.
babynames |>filter(name =="Clint"| name =="Leonardo"| name =="Marlon", sex =="M") %>%filter(year>1965)|>mutate(percent =round(prop *100, 1)) %>%ggplot(aes(x = year, y = percent, color = name)) +geom_line( size =1)
Above is a graph depicting the popularity of three celebrity names over time. Clint Eastwood reached his commercial peak in 1980. As the graph above and table below show, the name Clint also peaked around this time. Marlon Brando reached his commercial peak in the early 70’s with films such as “The Godfather” (1972) and later “Apocalypse Now”. Coincidentally, the name Marlon was most popular in 1972, as shown in the table below. Finally, Leonardo Dicaprio reached his commercial peak in the 1990’s with films such as “Titanic” (1997). The name Leonardo increased substantially after the release of Titanic.
babynames %>%filter(name =="Clint") %>%slice_max(prop, n =5) %>%mutate(rank =row_number()) %>%mutate(percent =round(prop *100, 2)) %>%select(year, percent, rank) |>gt() |>tab_header(title ="Peak Years of Popularity for the Name Clint ")
Peak Years of Popularity for the Name Clint
year
percent
rank
1980
0.07
1
1981
0.06
2
1977
0.06
3
1978
0.06
4
1979
0.06
5
babynames %>%filter(name =="Marlon") %>%slice_max(prop, n =5) %>%mutate(rank =row_number()) %>%mutate(percent =round(prop *100, 2)) %>%select(year, percent, rank) |>gt() |>tab_header(title ="Peak Years of Popularity for the Name Marlon ")
Peak Years of Popularity for the Name Marlon
year
percent
rank
1972
0.06
1
1973
0.06
2
1974
0.05
3
1976
0.05
4
1971
0.04
5
babynames %>%filter(name =="Leonardo") %>%slice_max(prop, n =20) %>%mutate(rank =row_number()) %>%mutate(percent =round(prop *100, 2)) %>%select(year, percent, rank) |>gt() |>tab_header(title ="Peak Years of Popularity for the Name Leonardo ")