Outline
- Motivation
- Functionality of trackeR
- Code examples and implementation detail
Questions to answer in the next 15 minutes:
- Why care?
- What can you do with trackeR?
- How does it work?
28 June 2016
Outline
Questions to answer in the next 15 minutes:
library("trackeR") filepath <- system.file("extdata", "2013-06-08-090442.TCX", package = "trackeR") runDF <- readTCX(file = filepath, timezone = "GMT") str(runDF)
## 'data.frame': 1191 obs. of 9 variables: ## $ time : POSIXct, format: "2013-06-08 08:04:42" ... ## $ latitude : num 51.4 51.4 51.4 51.4 51.4 ... ## $ longitude : num 1.04 1.04 1.04 1.04 1.04 ... ## $ altitude : num 6.2 6.2 6.2 6.2 6.2 ... ## $ distance : num 0 1.68 5.28 8.33 14.88 ... ## $ heart.rate: num 83 84 84 86 89 93 96 98 101 102 ... ## $ speed : num 0 0.594 1.416 1.928 2.614 ... ## $ cadence : num NA 54 74 97 97 97 97 98 97 97 ... ## $ power : num NA NA NA NA NA NA NA NA NA NA ...
runTr0 <- trackeRdata(runDF) runTr1 <- readContainer(filepath, type = "tcx", timezone = "GMT") identical(runTr0, runTr1)
## [1] TRUE
runTr2 <- readDirectory(system.file("extdata", package = "trackeR"), timezone = "GMT")
## Reading file /home/frick/lib/R/trackeR/extdata/2013-06-08-090442.TCX (file 1 out of 1) ... ## Cleaning up...Done
identical(runTr0, runTr2)
## [1] TRUE
data("runs", package = "trackeR")
plot(runs, session = c(3,13)) plotRoute(runs, session = 3, source = "osm") leafletRoute(runs, session = c(6,7,10,12,13,21))
summary(runs, session = 1)
## *** Session 1 *** ## ## Session times: 2013-06-01 17:32:15 - 2013-06-01 18:37:56 ## Distance: 14130.7 m ## Duration: 1.09 hours ## Moving time: 1.07 hours ## Average speed: 3.59 m_per_s ## Average speed moving: 3.67 m_per_s ## Average pace (per 1 km): 4:38 min:sec ## Average pace moving (per 1 km): 4:32 min:sec ## Average cadence: 88.66 steps_per_min ## Average cadence moving: 88.87 steps_per_min
## Average power: NA W ## Average power moving: NA W ## Average heart rate: 141.11 bpm ## Average heart rate moving: 141.13 bpm ## Average heart rate resting: 136.76 bpm ## Work to rest ratio: 42.31 ## ## Moving threshold: 1 m_per_s
runsSummary <- summary(runs) plot(runsSummary, what = c("avgSpeed", "distance"))
Summarise sessions with regard to speed, heart rate, etc:
## Change speed unit to miles per hour runs <- changeUnits(runs, variable = "speed", unit = "mi_per_h")
## Calculate and plot distribution profiles dProfiles <- distributionProfile(runs, what = "speed", grid = seq(0, 22, by = 0.1)) plot(dProfiles, multiple = TRUE)
## Calculate and plot concentration profiles cProfiles <- concentrationProfile(dProfiles) plot(cProfiles, multiple = TRUE)
## Functional principal components analysis (PCA) cpPCA <- funPCA(cProfiles, what = "speed", nharm = 4) plot(cpPCA, harm = 1:2)