Skip to content

Instantly share code, notes, and snippets.

@iangow
Last active April 9, 2017 14:34
Show Gist options
  • Save iangow/539a0eff0907b8449de4e668029ffd60 to your computer and use it in GitHub Desktop.
Save iangow/539a0eff0907b8449de4e668029ffd60 to your computer and use it in GitHub Desktop.
Code to make plots of Gemma's scores.
library(googlesheets)
library(ggplot2)
library(tidyr)
library(dplyr, warn.conflicts = FALSE)
gs <- gs_key("1vMzccNDQnGPLuNmRHe80okvEGZtHQt4xHFBscAZn5hc")
scores <- gs_read(gs)
scores
# Plot total scores over time
s <-
scores %>%
filter(!is.na(Total)) %>%
ggplot(aes(x = Date, y = Total)) +
geom_label(aes(label = Competition)) +
geom_line() +
scale_x_date(limits = c(as.Date("2017-01-15"), as.Date("2017-05-31"))) +
theme(axis.text.y=element_blank())
print(s)
# Save plot as a square for Instagram
ggsave(plot = s,
device = "png",
filename = "~/Desktop/totals.png", width = 5, height = 5)
p <- scores %>%
select(-Total) %>%
gather(key = Routine, value = Score, Floor:Clubs) %>%
ggplot(aes(x = Date, y = Score, group = Routine, shape = Competition,
colour = Routine)) +
geom_line() +
geom_point() +
scale_x_date() +
theme(axis.text.y=element_blank())
print(p)
# Save plot as a square for Instagram
ggsave(plot = p,
device = "png",
filename = "~/Desktop/by_routine.png", width = 5, height = 5)
@iangow
Copy link
Author

iangow commented Apr 9, 2017

TODO:

  • Add future events with dates (otherwise, missing values).
  • Add trend line with extrapolation to the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment