Bikeride DataViz



I sincerely do not intend this post to be a personal manifestation of bragging about exercising by posting about it online. I hope it is not misconstrued as such. However, I am very comfortable with the notion that this post boils down to showing off a new tool, because that is precisely what brings me here. 

Short and sweet- I went on a bike ride and had Runkeeper, an exercise tracking app, record the data. For each of the 20 miles, it recorded my speed and elevation gain/loss. This ride consisted of 2 ten mile loops around Lake Maxinkuckee. The first loop I rode alongside my mom, and the second loop I was alone. I had a feeling that I went much faster the second loop, but further analysis was deemed necessary to test this hypothesis.

I manually entered the numbers and created a dataframe in R. I have included the code at the bottom of this post for those who may be interested. Using ggplot2, I created the below visual. Note- the vertical dotted blue line indicates the separation between lap 1 and 2.



It seems pretty clear that I was faster overall the second lap. But was I consistently faster for each mile?

One slightly bizarre outlier is my overall fastest mile, mile #13. I averaged 19.68 MPH, but also gained elevation during that mile. Perhaps research is in order to find out how I went comparatively so much faster that mile than the rest given the elevation gain. Maybe it is an overall downhill section with a sharp hill at the very end. I digress, below we can see the next iteration of the visual:







The first and second lap are again clearly distinguished. The gray portion surrounding both lines is the standard error at a .95 level, and it seems the two would not overlap. i.e, 2nd lap is much faster than the first. To improve the visual again, we can stack the two laps on top of each other. If interested, see below how the data was edited to affect the visual














 This plot pretty unequivocally shows that the 2nd lap was much faster overall than the first. The only time that the first and second laps' standard error fields overlap is at the final mile of the lap. Perhaps I did not push as hard on the home stretch as I could have. No eureka moments here, but it is certainly rewarding (for me at least) to use programming languages and visualizations to prove a point.

Thanks for reading, and I hope you enjoyed the ride シ









Source Code:

#Manual Input of Code
bike_time_splits <- c(11.59,13.81,13.65,12.65,13.80,14.99,13.59,14.97, 13.29, 13.66, 17.45,16.69,19.68,18.24,17.46,17.57,17.14,17.05,16.33,15.54)
Climb <- c(16,-19,21,-11,30,-33,18,-8,-17,1,19,-11,20,-6,-1,25,-35,-11,14,-1)

#Creating Data Frame
bike_time_data_frame <- data.frame(bike_time_splits, row.names= c(1:20))
bike_time_data_frame$Mile <- c(1:20)
bike_time_data_frame$Climb <- Climb
colnames(bike_time_data_frame) <- c("MPH", "Mile", "Climb")

#Original Plot
ggplot(bike_time_data_frame, aes(x=Mile, y=MPH, color=Climb)) +
  geom_point(size=4) +
  geom_smooth()+
  geom_vline(xintercept=10,linetype="F1", size=1,color="blue") +
  ggtitle("September 14th Bike Ride") +
  theme(plot.background = element_rect(fill = "#BFD5E3"))

#Adding Loop Field
Loop <- factor(c(rep(1,10), rep(2,10))); Loop
length(Loop)
bike_time_data_frame$Loop <- Loop

#Plotting 2 loops next to eachother
ggplot(bike_time_data_frame, aes(x=Mile, y=MPH, color=Loop)) +
  geom_point(size=4) +
  geom_smooth()+
  ggtitle("September 14th Bike Ride") +
  theme(plot.background = element_rect(fill = "#BFD5E3"))

#Reformulating DataFrame columnas 2 ten mile loops
bike_time_data_frame$Mile <- rep(1:10,2)

#New Plot with both laps stacked
ggplot(bike_time_data_frame, aes(x=Mile, y=MPH, color=Loop)) +
  geom_point(size=4) +
  geom_smooth(level=.9)+
  ggtitle("September 14th Bike Ride") +
  theme(plot.background = element_rect(fill = "#BFD5E3"))



































Comments

Popular posts from this blog

Using a Neural Network to Predict Pneumonia From X-Ray Images

Using a Neural Network to Classify Lego Figures

Artwork Locator