Giter Site home page Giter Site logo

running's Introduction

Running data

This repository stores RunningData.csv, in which I record information about each of my runs (e.g. distance, time, average pace).

# Read data, format dates and times
runningData <- read.csv("RunningData.csv")
runningData$Date <- as.Date(runningData$Date, format="%m/%d/%y")
runningData$Average_Pace <- as.POSIXct(runningData$Average_Pace, format="%M:%S")

# Plots 
library(ggplot2); library(ggpubr); library(scales)
plotSettings <- list(theme_minimal(), geom_line(color="gray70"), geom_point(aes(color=Treadmill_Road)), scale_color_manual(values=c(alpha("green3", 0.8), alpha("orange3", 0.8), alpha("dodgerblue3", 0.8))), theme(plot.title=element_text(hjust=0.5)), theme(legend.position="none"), scale_x_date(date_breaks="1 month", date_labels="%B-%y"), theme(axis.text.x=element_text(angle=45, vjust=1, hjust=1)))
p1 <- ggplot(runningData, aes(x=Date, y=Miles)) + geom_hline(yintercept=13.1, linetype="dotted", color = "mistyrose4") + geom_text(label="13.1 (half marathon)", x=as.Date("2021-11-30"), y=13.8, color="mistyrose4", size=2.5) + labs(y="Distance (miles)", title="How far I ran") + plotSettings + scale_y_continuous(breaks=seq(0,30,2))
p2 <- ggplot(runningData, aes(x=Date, y=Average_Pace)) + labs(y="Minutes", title="Average pace (time per mile)") + scale_y_datetime(breaks=date_breaks("1 mins"), date_labels="%M:%S") + labs(color="Type of run") + plotSettings +  theme(legend.position=c(0.05, 0.2), legend.background=element_rect(size=0.1, linetype="solid", color="black"), legend.margin=margin(2,3,2,3), legend.title=element_text(size=9, face="bold"), legend.text=element_text(size=8)) + guides(color=guide_legend(override.aes=list(size=1)))
ggarrange(p1, p2, nrow=2)

# runningData$Year <- format(runningData$Date, "%Y")
# ggplot(runningData[runningData$Year > "2021",], aes(x = Miles)) + geom_histogram(aes(y = ..density..), color = "black", fill = "gray") + facet_grid(. ~ Year)

Total miles since 11/29/21:

sum(runningData$Miles)
## [1] 2026.47

Average distance over last ten runs:

mean(tail(runningData$Miles, 10))
## [1] 8.418

running's People

Contributors

sara-venkatraman avatar

Watchers

 avatar Aditya Soni avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.