Running Around: an R package to analyze Garmin running data | R bloggers

Running Around: an R package to analyze Garmin running data | R bloggers

2 minutes, 40 seconds Read

[This article was first published on Rstats – quantixed, and kindly contributed to R-bloggers]. (You can report a problem with the content on this page here)


Want to share your content on R bloggers? click here if you have a blog, or here if you don’t.


In my previous messageI shared my annual running stats generated in R using summary data from Garmin Connect. The code I use to generate these summaries was starting to get a bit clunky, so I’ve now converted it into a package.

GarminCSVr – is an R package for viewing running data using the activity summaries downloadable from the Garmin Connect website. This post is to show what the package can do.

Annual summary

There are two main workflows. The first – summarise_activities() – is designed to provide an annual overview of running data, with an annual distance goal in mind. See below how to organize the Garmin data before running the code.

# install.packages("devtools")
devtools::install_github("quantixed/GarminCSVr")
library(GarminCSVr)
## my 2025 running goal was 3650 km
summarise_activities(from = "2025-01-01", to = "2025-12-31", annual = 3650)

This generates these plots to visualize progress:

Observant readers may notice that I’ve also updated the calendar view of runs per day and distances per day to make it easier to interpret.

Compare years of activities

In the second function – compare_years() – we can compare annual performance year after year.

# compare 2018 through to 2025
compare_years(from = "2018-01-01", to = "2025-12-31")

This feature also outputs some heart rate data that I’m not posting here.

Usage

Currently, activities in Garmin Connect can be opened and filtered for running, as shown in the screenshot. This link currently takes you to the correct screen, but may change in the future.

If you click Export CSV you can download all displayed activities. As you scroll down, more and more past activities are loaded, allowing you to export everything if you go back far enough.

Grabbing this CSV summary is easier than wrangling with the API. If you collect all your past activities and then download the past weeks/months, you can add all the CSV files to a folder and {GarminCSVr} will handle any duplications.

If you are working in a clean RStudio project, place the files in a folder named Data within the project and the code runs automatically and saves the plots Output/Data in the project/work folder. The files may be located somewhere else, you just need to tell GarminCSVr where to find them using the datadir argument.

The pack is designed for running, but should also work with cycling or swimming. Just change the activity argument and you should be good to go.

Finally, if you want to try out GarminCSVr but don’t have any files, I’ve included some dummy data. Just run:

# devtools::install_github("quantixed/GarminCSVr")
library(GarminCSVr)
# example data included in the package
# summarise activities for 2025 with a target of 1500 km
summarise_activities(datadir = system.file("extdata",package = "GarminCSVr"),
                     from = "2025-01-01", to = "2025-12-31", target = 1500)
# comparison of years using the example data
compare_years(datadir = system.file("extdata",package = "GarminCSVr"))

The title of the message is taken from “Running Around” by DRI


#Running #package #analyze #Garmin #running #data #bloggers

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *