Exercises 11 - ggplot Solutions

Files corresponding to Short Course: Introduction to Data Science Using R

Exercises 11 - ggplot Solutions

We’ll continue to work on the same .Rmd file from the previous exercise.


11.1

  1. Use the data object created by the code below to create a line plot (via geom_line()) that looks like the one below.
names <- c("Justin", "George", "Alexander", "Jacob", "Anderson")
lineData <- BabyNamesFull %>%
  filter(name %in% names) %>% 
  group_by(name, year) %>%
  summarise(total = sum(count))
## `summarise()` has grouped output by 'name'. You can override using the `.groups` argument.
ggplot(lineData) +
 geom_line(aes(x = year, y = total, color = name))