## # A tibble: 1,924,665 x 5
## year sex name n prop
## <dbl> <chr> <chr> <int> <dbl>
## 1 1880 F Mary 7065 0.0724
## 2 1880 F Anna 2604 0.0267
## 3 1880 F Emma 2003 0.0205
## 4 1880 F Elizabeth 1939 0.0199
## 5 1880 F Minnie 1746 0.0179
## 6 1880 F Margaret 1578 0.0162
## 7 1880 F Ida 1472 0.0151
## 8 1880 F Alice 1414 0.0145
## 9 1880 F Bertha 1320 0.0135
## 10 1880 F Sarah 1288 0.0132
## # ... with 1,924,655 more rows
## # A tibble: 138 x 5
## year sex name n prop
## <dbl> <chr> <chr> <int> <dbl>
## 1 1880 M Joseph 2632 0.0222
## 2 1881 M Joseph 2456 0.0227
## 3 1882 M Joseph 2670 0.0219
## 4 1883 M Joseph 2515 0.0224
## 5 1884 M Joseph 2707 0.0221
## 6 1885 M Joseph 2540 0.0219
## 7 1886 M Joseph 2594 0.0218
## 8 1887 M Joseph 2456 0.0225
## 9 1888 M Joseph 2993 0.0230
## 10 1889 M Joseph 2729 0.0229
## # ... with 128 more rows
Joseph %>%
ggplot()+
geom_col(fill = "#87CEEB", color ="white", aes(x=year, y= n))+
geom_col(fill = "#008fd5", color="white", data= Joseph %>% filter(year == 1956),
aes(x=year, y= n))+
geom_line(aes(year, n),size=2)+
geom_text(label = "Joseph was the most popular name in 1956",
color="grey30", x= 1924, y=33000, size= 4)+
theme_fivethirtyeight()+
theme(text = element_text(family = "Arial Black", size = 13, color = "gray30")) +
theme(plot.caption = element_text(size = 12, color = "grey40", family = "Arial", face = "bold")) +
theme(axis.text.y = element_text(color = "grey30", size = 10)) +
theme(axis.text.x = element_text(color = "grey30", size = 10)) +
theme(plot.subtitle = element_text(color = "gray30", size = 10, family = "Arial")) +
theme(plot.margin = unit(c(1.2, 1.2, 1.2, 1.2), "cm")) +
labs(title = "Distribution of American Boys Named Joseph",
subtitle = "By year of birth",
caption = "Data Source: Social Security Administration (SSA).")

## [1] 1880 1880 1881 1881 1882 1882 1883 1883 1884 1884 1885 1885 1886 1886 1887
## [16] 1887 1888 1888 1889 1889 1890 1890 1891 1891 1892 1892 1893 1893 1894 1894
## [31] 1895 1895 1896 1896 1897 1897 1898 1898 1899 1899 1900 1900 1901 1901 1902
## [46] 1902 1903 1903 1904 1904 1905 1905 1906 1906 1907 1907 1908 1908 1909 1909
## [61] 1910 1910 1911 1911 1912 1912 1913 1913 1914 1914 1915 1915 1916 1916 1917
## [76] 1917 1918 1918 1919 1919 1920 1920 1921 1921 1922 1922 1923 1923 1924 1924
## [91] 1925 1925 1926 1926 1927 1927 1928 1928 1929 1929 1930 1930 1931 1931 1932
## [106] 1932 1933 1933 1934 1934 1935 1935 1936 1936 1937 1937 1938 1938 1939 1939
## [121] 1940 1940 1941 1941 1942 1942 1943 1943 1944 1944 1945 1945 1946 1946 1947
## [136] 1947 1948 1948 1949 1949 1950 1950 1951 1951 1952 1952 1953 1953 1954 1954
## [151] 1955 1955 1956 1956 1957 1957 1958 1958 1959 1959 1960 1960 1961 1961 1962
## [166] 1962 1963 1963 1964 1964 1965 1965 1966 1966 1967 1967 1968 1968 1969 1969
## [181] 1970 1970 1971 1971 1972 1972 1973 1973 1974 1974 1975 1975 1976 1976 1977
## [196] 1977 1978 1978 1979 1979 1980 1980 1981 1981 1982 1982 1983 1983 1984 1984
## [211] 1985 1985 1986 1986 1987 1987 1988 1988 1989 1989 1990 1990 1991 1991 1992
## [226] 1992 1993 1993 1994 1994 1995 1995 1996 1996 1997 1997 1998 1998 1999 1999
## [241] 2000 2000 2001 2001 2002 2002 2003 2003 2004 2004 2005 2005 2006 2006 2007
## [256] 2007 2008 2008 2009 2009 2010 2010 2011 2011 2012 2012 2013 2013 2014 2014
## [271] 2015 2015 2016 2016 2017 2017
df %>%
ggplot(aes(year, n, color = sex)) +
geom_line(size= 1.5, show.legend = FALSE)+
scale_y_continuous(limits = c(0,40000,10000))+
scale_color_manual(values= c("#3d6a51", "#f15c42")) +
annotate("text", label = "Joseph was popular among American boys name",
x= 1950, y=38000, family = my_font)+
annotate("text", label = "Joseph is not for girls' name till 2017",
x= 1970, y= 5000, family= my_font)+
geom_curve(x= 1940, xend =1950, y = 35000, yend = 33000, arrow = arrow(length = unit(0.5,"cm")), curvature =0.1)+
theme_fivethirtyeight()+
scale_x_continuous(breaks = seq(1880, 2017, 20))+
theme(plot.margin = unit(c(1.2, 1.2, 1.2, 1.2), "cm")) +
labs(title = "Distribution of Named Joseph",
subtitle = "By Gender",
caption = "Data Source: Social Security Administration (SSA).")+
theme(axis.text.x = element_text(color ="grey30", size=10))+
theme(text = element_text(family = "Arial Black", size = 13, color = "gray30")) +
theme(plot.caption = element_text(size = 12, color = "grey40", family = "Arial", face = "bold")) +
theme(axis.text.y = element_text(color = "grey30", size = 10)) +
theme(axis.text.x = element_text(color = "grey30", size = 10)) +
theme(plot.subtitle = element_text(color = "gray30", size = 10, family = "Arial")) +
theme(plot.margin = unit(c(1.2, 1.2, 1.2, 1.2), "cm"))

## # A tibble: 15 x 6
## # Groups: year, sex [1]
## year sex name n prop text_color
## <dbl> <chr> <chr> <int> <dbl> <chr>
## 1 2017 F Emma 19738 0.0105 Indianred2
## 2 2017 F Olivia 18632 0.00994 gray20
## 3 2017 F Ava 15902 0.00848 gray20
## 4 2017 F Isabella 15100 0.00805 gray20
## 5 2017 F Sophia 14831 0.00791 gray20
## 6 2017 F Mia 13437 0.00717 gray20
## 7 2017 F Charlotte 12893 0.00688 gray20
## 8 2017 F Amelia 11800 0.00629 gray20
## 9 2017 F Evelyn 10675 0.00569 gray20
## 10 2017 F Abigail 10551 0.00563 gray20
## 11 2017 F Harper 10451 0.00557 gray20
## 12 2017 F Emily 9746 0.00520 gray20
## 13 2017 F Elizabeth 8915 0.00475 gray20
## 14 2017 F Avery 8186 0.00437 gray20
## 15 2017 F Sofia 8134 0.00434 gray20
hotnames %>%
ggplot(aes(x=reorder(name,n), y=n))+
geom_col(col = "white", fill ="#073763")+
geom_text(aes(label = paste0(n),
), color = "white",
hjust = 1.5)+
coord_flip()+
theme_fivethirtyeight()+
scale_y_continuous(breaks = seq(0,20000, 5000)) +
theme(plot.margin = unit(c(1.2, 1.2, 1.2, 1.2), "cm")) +
annotate("text",label = "Emma & Olivia are the hottest name in 2017",
y= 16000, x= 2.8, size= 3)+
labs(title = "The most popular name lists in 2017",
subtitle = "Analzying only female data in 2017",
caption = "Data Source: Social Security Administration (SSA).")+
theme(axis.text.y = element_text(color ="grey30", size=10))+
theme(axis.text.x = element_text(color = Emma_color$text_color))+
theme(text = element_text(family = "Arial Black", size = 13, color = "gray30")) +
theme(plot.caption = element_text(size = 10, color = "grey40", family = "Arial",
face = "bold")) +
theme(axis.text.y = element_text(color = "grey30", size = 10)) +
theme(axis.text.x = element_text(color = "grey30", size = 10)) +
theme(plot.title = element_text(size= 15))+
theme(plot.subtitle = element_text(color = "gray30", size = 10, family = "Arial")) +
theme(plot.margin = unit(c(1.4, 1.4, 1.4, 1.4), "cm"))
