Last active
May 1, 2017 08:41
-
-
Save sisao/78cf7d73f9d801abbf4ea1b51a1df7c2 to your computer and use it in GitHub Desktop.
"Power in zones over time" graph in R for GoldenCheetah
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$$activity <- GC.activity() | |
$$metrics <- GC.metrics() | |
$$date <- $$metrics$date | |
$$zone <- GC.athlete.zones(date=$$date, sport="bike") | |
$$lows <- $$zone$zoneslow | |
$$colors <- $$zone$zonescolor | |
$$duration <- tail($$activity$seconds, n=1) | |
$$p <- $$activity$power | |
$$n = 10 | |
$$group <- split($$p, ceiling(seq_along($$p)/$$n)) | |
$$p2 <- sapply($$group, mean) | |
$$time <- $$activity$seconds[seq(1, length($$activity$seconds), $$n)] | |
$$breaks <- c(unlist($$lows), Inf) | |
$$cols <- c(unlist($$colors))[findInterval($$p2, vec=$$breaks)] | |
$$displaytime <- function(timevalue) { | |
$$totalMinutes <- timevalue %/% 60 | |
$$totalSeconds <- sprintf("%02d", timevalue %% 60) | |
paste($$totalMinutes, $$totalSeconds, sep=":") | |
} | |
barplot($$p2, | |
names.arg=lapply($$time, $$displaytime), | |
space=0, border=NA, | |
col=$$cols | |
) | |
title(main="Power in zones", ylab = "Watts", xlab = "Time") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment