Skip to content

Instantly share code, notes, and snippets.

@stiles
Last active December 14, 2015 13:28
Show Gist options
  • Save stiles/5093356 to your computer and use it in GitHub Desktop.
Save stiles/5093356 to your computer and use it in GitHub Desktop.
Baby names
#set working directory
setwd("~/Dropbox/code-data")
# Set up
library(plyr)
library(ggplot2)
# load data
## Make sure data sets are in your working directory
options(stringsAsFactors = FALSE)
bnames <- read.csv("bnames.csv")
births <- read.csv("births.csv")
# peek at bnames
head(bnames)
str(bnames)
#draw bnames line graph
name <- subset(bnames, name == "Tracy" & sex == "girl" | name == "Matthew" & sex == "boy" | name == "Brian" & sex == "boy" | name == "Ellen" & sex == "girl" | name == "Cara" & sex == "Girl" | name == "Keith" & sex == "boy" | name == "Mark" & sex == "boy" | name == "Charles" & sex == "boy" )
qplot(year, prop, data = name, geom = "line", color = name) +
ggtitle("Baby Names: 1880-2008") + geom_text( vjust=0, colour="red", label = name )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment