Skip to content

Instantly share code, notes, and snippets.

@aholmes
Last active June 15, 2023 17:46
Show Gist options
  • Save aholmes/8ed51c7aeeb3427ac8cd9cae1e15dfcb to your computer and use it in GitHub Desktop.
Save aholmes/8ed51c7aeeb3427ac8cd9cae1e15dfcb to your computer and use it in GitHub Desktop.
Horrible R code to chart Drumeo 10 minute exercise over a month.
# the csv data
# date,2023-04-08,2023-04-09,2023-04-10,2023-04-11,2023-04-12,2023-04-13,2023-04-14,2023-04-15,2023-04-16,2023-04-17,2023-04-18,2023-04-19,2023-04-20,2023-04-21,2023-04-22,2023-04-23,2023-04-24,2023-04-25,2023-04-26,2023-04-27,2023-04-28,2023-04-29,2023-04-30,2023-05-01,2023-05-02,2023-05-03,2023-05-04,2023-05-05,2023-05-06,2023-05-07,2023-05-08,2023-05-09
# 1min,120,120,125,130,130,135,140,145,145,145,146,147,150,152,155,155,156,157,158,158,158,157,158,158,158,158,158,158,160,160,160,161
# 2min,120,120,125,125,126,130,130,132,133,134,135,140,145,150,150,150,152,152,148,148,149,145,150,151,147,145,147,150,151,151,152,153
# 3min,120,120,122,123,125,127,130,131,132,133,135,136,140,140,142,143,144,145,144,145,146,140,146,146,140,135,145,146,146,146,147,148
# 4min,110,120,115,112,120,122,123,125,124,125,126,127,130,133,135,133,135,130,130,131,132,120,133,130,120,120,135,135,136,136,137,139
function(data, which) {
colors <- c("black","red","green","blue")
plot_data <- data[data[1] == which[1]]
plot(plot_data[2: length(plot_data) ], type='o', ylim=c(110,170))
legend(1, 170, legend=which, col=colors, lty=1:2)
i <- 2
for (w in which[2:length(which)]) {
plot_data <- data[data[1] == w]
lines(plot_data[2: length(plot_data) ], type='o', col=colors[[i]], ylab=w)
i <- i + 1
}
}
plot_data<-read.csv('records.csv')
plot_the_data(plot_data,c('1min','2min','3min','4min'))
# chart output here:
# https://i.imgur.com/69iTiwY_d.jpg?maxwidth=520&shape=thumb&fidelity=high
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment