https://github.com/trackerproject/tracker
Infrastructure for Running, Cycling and Swimming Data from GPS-Enabled Tracking Devices
https://github.com/trackerproject/tracker
Last synced: 2 months ago
JSON representation
Infrastructure for Running, Cycling and Swimming Data from GPS-Enabled Tracking Devices
- Host: GitHub
- URL: https://github.com/trackerproject/tracker
- Owner: trackerproject
- Created: 2015-10-15T18:16:52.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-01-12T17:13:38.000Z (about 2 years ago)
- Last Synced: 2024-10-25T00:34:32.383Z (over 1 year ago)
- Language: HTML
- Homepage: http://cran.r-project.org/package=trackeR
- Size: 33.6 MB
- Stars: 90
- Watchers: 15
- Forks: 7
- Open Issues: 7
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---
# trackeR 
[](https://cran.r-project.org/package=trackeR)
[](https://coveralls.io/github/trackerproject/trackeR?branch=master)
[](https://github.com/trackerproject/trackeR/actions/workflows/R-CMD-check.yaml)
[](https://www.gnu.org/licenses/gpl-3.0.en.html)
### Description
The purpose of this package is to provide infrastructure for handling
running, cycling, and swimming data from GPS-enabled tracking devices.
The formats that are currently supported for the training activity
files are .tcx (Training Center XML), Strava .gpx, .db3 and [Golden
Cheetah](http://goldencheetah.org) .json files. After extraction and
appropriate manipulation of the training or competition attributes,
the data are placed into session-based and unit-aware data objects of
class trackeRdata (S3 class). The information in the resultant data
objects can then be visualised, summarised, and analysed through
corresponding flexible and extensible methods.
### Current capabilities
Read:
- Read data from .tcx, Strava .gpx, .db3 or [Golden Cheetah](http://goldencheetah.org) .json files.
- Read all supported files in a specified directory.
Sports supported:
- Running
- Cycling
- Swimming
Data processing:
- Automatically identify sessions from timestamps.
- Imputation of data to characterise times when the device is paused or remains stationary.
- Correction of GPS-measured distances using elevation data.
- Basic data cleaning capabilities e.g., no negative speeds or distances.
- Specify and conveniently change units of measurement.
- Organise data into session-based and unit-aware data objects of class trackeRdata.
Analysis:
- Session summaries: distance, duration, time moving, average speed/pace/heart
rate/cadence/power (overall and moving), work to rest ratio, temperature.
- Time spent exercising in user-supplied zones, e.g., heart rate zones or speed zones.
- Work capacity above critical power (W', W prime)
- Distribution profiles: time spent exercising above thresholds of training attributes.
- Concentration profiles: negative derivatives of distribution profiles.
- Functional principal components analysis of distribution and concentration profiles.
Visualisation:
- Plot session progression in, e.g., pace, heart rate, etc.
- Plot route covered during session on static and interactive maps from various providers.
- Plot session summary statistics.
- Plot date time of sessions in timeline plots.
- Plot time spent exercising in zones.
- Plot distribution/concentration profiles.
- Plot principal components of distribution/concentration profiles.
- Ridgeline (or joy) plots for distribution/concentration profiles.
### Installation
Install the released version from CRAN:
```{r, eval = FALSE}
install.packages("trackeR")
```
Or the development version from github:
```{r, eval = FALSE}
# install.packages("devtools")
devtools::install_github("trackerproject/trackeR")
```
### Example
Plot workout data
```{r, plots, message = FALSE, fig.height = 6.5}
data(runs, package = "trackeR")
plot(runs, session = 1:5, what = c("speed", "pace", "altitude"))
```
Change the units
```{r, plots_new, message = FALSE, fig.height = 6.5}
data(runs, package = "trackeR")
runs0 <- change_units(runs,
variable = c("speed", "altitude"),
unit = c("km_per_h", "ft"),
sport = c("running", "running"))
plot(runs0, session = 1:5, what = c("speed", "pace", "altitude"))
```
Summarise sessions
```{r, summary, message = FALSE, fig.height = 6.5}
library("trackeR")
runs_summary <- summary(runs)
plot(runs_summary, group = c("total", "moving"),
what = c("avgSpeed", "distance", "duration", "avgHeartRate"))
```
Generate distribution and concentration profiles
```{r, cprofile, fig.width = 9}
runsT <- threshold(runs)
dp_runs <- distribution_profile(runsT, what = c("speed", "heart_rate"))
dp_runs_smooth <- smoother(dp_runs)
cp_runs <- concentration_profile(dp_runs_smooth)
plot(cp_runs, multiple = TRUE, smooth = FALSE)
```
A ridgeline plot of the concentration profiles
```{r, cprofile-ridges, warning = FALSE, fig.width = 9}
ridges(cp_runs, what = "speed")
```
```{r, cprofile-ridges-hr, warning = FALSE, fig.width = 9}
ridges(cp_runs, what = "heart_rate")
```
Explore concentration profiles for speed, e.g., via functional principal
components analysis (PCA)
```{r, funPCA, fig.width = 7, fig.height = 7}
## fit functional PCA
cp_PCA <- funPCA(cp_runs, what = "speed", nharm = 4)
## pick first 2 harmonics/principal components
round(cp_PCA$varprop, 2)
## plot harmonics
plot(cp_PCA, harm = 1:2)
```
```{r, scores}
## plot scores vs summary statistics
scores_SP <- data.frame(cp_PCA$scores)
names(scores_SP) <- paste0("speed_pc", 1:4)
d <- cbind(runs_summary, scores_SP)
library("ggplot2")
## pc1 ~ session duration (moving)
ggplot(d) + geom_point(aes(x = as.numeric(durationMoving), y = speed_pc1)) + theme_bw()
## pc2 ~ avg speed (moving)
ggplot(d) + geom_point(aes(x = avgSpeedMoving, y = speed_pc2)) + theme_bw()
```