The trackeR package provides infrastructure for handling running and cycling data from GPS-enabled tracking devices. A short demonstration of its functionality is provided below, based on data from running activities. A more comprehensive introduction to the package can be found in the vignette “Infrastructure for Running and Cycling Data”, which can be accessed by typing
trackeR can currently import files in the Training Centre XML (TCX) format and .db3 files (SQLite databases, used, for example, by devices from GPSports) through the corresponding functions readTCX() and readDB3(). It also offers support for JSON files from Golden Cheetah via readJSON().
library("trackeR")
filepath <- system.file("extdata/tcx/", "2013-06-01-183220.TCX.gz", package = "trackeR")
runDF <- readTCX(file = filepath, timezone = "GMT")
These read functions return a data.frame
of the
following structure
str(runDF)
#> 'data.frame': 3881 obs. of 11 variables:
#> $ time : POSIXct, format: "2013-06-01 17:32:20" "2013-06-01 17:32:21" ...
#> $ latitude : num 50.8 50.8 50.8 50.8 50.8 ...
#> $ longitude : num -1.7 -1.7 -1.7 -1.7 -1.7 ...
#> $ altitude : num 83.4 83.8 84 83.8 83.6 ...
#> $ distance : num 1.26 3.3 7.12 11.12 16.76 ...
#> $ heart_rate : num 56 61 61 71 71 74 74 85 85 85 ...
#> $ speed : num 0.885 1.209 1.801 2.205 2.756 ...
#> $ cadence_running: num 60 63 70 78 83 84 84 85 85 86 ...
#> $ cadence_cycling: logi NA NA NA NA NA NA ...
#> $ power : logi NA NA NA NA NA NA ...
#> $ temperature : logi NA NA NA NA NA NA ...
#> - attr(*, "sport")= chr "running"
#> - attr(*, "file")= chr "/private/var/folders/qs/10p81dxs38z8pxqhdcqfvvdh0000gp/T/RtmpKXZwf0/Rinstdad9248ac351/trackeR/extdata/tcx//2013"| __truncated__
That data.frame
can be used as an input to the
constructor function for trackeR’s trackeRdata
class, to produce a session-based and unit-aware object that can be used
for further analyses.
runTr0 <- trackeRdata(runDF)
#> Warning in sanity_checks(dat = dat, silent = silent): Observations with
#> duplicated time stamps have been removed.
The read_container() function combines the two steps of importing the data and constructing the trackeRdata object.
runTr1 <- read_container(filepath, type = "tcx", timezone = "GMT")
#> Warning in sanity_checks(dat = dat, silent = silent): Observations with
#> duplicated time stamps have been removed.
identical(runTr0, runTr1)
#> [1] TRUE
The read_directory() function can be used to read
all
supported files in a directory and produce the
corresponding trackeRdata objects.
The package includes an example data set which can be accessed through
The default behaviour of the plot method for trackeRdata objects is to show how heart rate and pace evolve over the session.
The elevation profile of a training session is also accessible, here along with the pace.
The route taken during a training session can also be plotted on maps from various sources e.g., from Google or OpenStreetMap. This can be done either on a static map