Skip to content

Instantly share code, notes, and snippets.

@mattm
Created April 19, 2017 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattm/17646e5e87e73bba9a56f22f3804d724 to your computer and use it in GitHub Desktop.
Save mattm/17646e5e87e73bba9a56f22f3804d724 to your computer and use it in GitHub Desktop.
Stacked Area Chart - Tidyr Solution
data <- read.csv("data.csv", sep = "\t")
data <- data %>%
tidyr::spread(key = plan, value = signups, fill = 0) %>%
tidyr::gather(key = plan, value = signups, - week) %>%
arrange(week, plan)
g <- ggplot(data, aes(x = week, y = signups, group = plan, fill = plan)) +
geom_area(position = "stack")
print(g)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment