Files with extension .Rmd are R Markdown files. We are going to practice compiling .Rmd files, i.e. knit them, to HTML pages.
problem_set_01Using a combination of Google, your instincts, and/or trial and error, find an one example of a name for a given sex whose popularity trend you find interesting. Add a sentence or two about your hypothesis as to why we see this trend. You’ll be copying over code from the example babynames.Rmd done in class for Lec03 below:
# Load packages
library(ggplot2)
library(dplyr)
library(babynames)
# Compute counts/proporations for "Other" names
other <- babynames %>%
group_by(year, sex) %>%
summarise(sum_n=sum(n), sum_prop=sum(prop)) %>%
mutate(
total = sum_n/sum_prop,
name = "Other",
prop = 1-sum_prop,
n = prop * total
) %>%
select(year, sex, name, n, prop)
# Add "Other" names to babynames
babynames <- babynames %>%
bind_rows(other) %>%
arrange(year, sex, desc(n))
baby_name <- "Hope"
baby_sex <- "F"
single_name <- babynames %>%
filter(name==baby_name & sex==baby_sex)
ggplot(data=single_name, mapping = aes(x=year, y=prop)) +
geom_line() +
xlim(c(1880, 2014)) +
ylim(c(0, NA)) +
xlab("Year") +
ylab(paste("Prop. of ", baby_sex, " born with name ", baby_name, sep=""))
There is an interesting trend for the name Hope with extreme dips and peaks. I notice that it peaks during new waves in history such as the Harlem Renaissance and then the 70s where a lot of technology was booming and then in 2000, the new millenium. The dips might represent times of struggle in the United States where there was not much hope.
You do not need to do submit anything in this section, but please give it a quick read:
What is R Markdown? It’s R + Markdown. What is Markdown? Markdown is a way to quickly write HTML code to publish to a webpage. We will be learning these on an “as needed basis”, but take a look and the commands below, and see what they look like after you Knit the page; they are rather simple to understand. You can see a full list of Markdown commands by going to RStudio menu bar -> Help -> Markdown Quick Reference.
Quick lists:
Quick URLs: https://www.nhl.com/
Quick numbered lists:
Tables:
| First Header | Second Header |
|---|---|
| Content Cell | Content Cell |
| Content Cell | Content Cell |
LaTeX for fancy math equations:
\(\frac{1}{\sqrt{2\pi\sigma^2}}\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)\)