Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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