Title: | Infrastructure for Running, Cycling and Swimming Data from GPS-Enabled Tracking Devices |
---|---|
Description: | Provides infrastructure for handling running, cycling and swimming data from GPS-enabled tracking devices within R. The package provides methods to extract, clean and organise workout and competition data into session-based and unit-aware data objects of class 'trackeRdata' (S3 class). The information can then be visualised, summarised, and analysed through flexible and extensible methods. Frick and Kosmidis (2017) <doi: 10.18637/jss.v082.i07>, which is updated and maintained as one of the vignettes, provides detailed descriptions of the package and its methods, and real-data demonstrations of the package functionality. |
Authors: | Ioannis Kosmidis [aut, cre] |
Maintainer: | Ioannis Kosmidis <[email protected]> |
License: | GPL-3 |
Version: | 1.6.0 |
Built: | 2025-03-07 06:07:38 UTC |
Source: | https://github.com/trackerproject/tracker |
Generic function for appending data to existing files
append(object, file, ...)
append(object, file, ...)
object |
The object to be appended. |
file |
The file to which |
... |
Arguments to be passed to methods. |
Append training sessions to existing file
## S3 method for class 'trackeRdata' append(object, file, ...)
## S3 method for class 'trackeRdata' append(object, file, ...)
object |
The object to be appended. |
file |
The file to which |
... |
Currently not used. |
Transform concentration profile to distribution profile.
c2d(cp)
c2d(cp)
cp |
Single concentration profile as a zoo object. |
Generic function for changing the units of measurement
change_units(object, variable, unit, sport, ...) changeUnits(object, variable, unit, sport, ...)
change_units(object, variable, unit, sport, ...) changeUnits(object, variable, unit, sport, ...)
object |
The object of which the units of measurement are changed. |
variable |
A vector of variables whose units are to be changed. |
unit |
A vector with the units, corresponding to |
sport |
A vector of sports (among |
... |
Arguments to be passed to methods. |
conProfile
objectChange the units of the variables in an conProfile
object
## S3 method for class 'conProfile' change_units(object, variable, unit, ...)
## S3 method for class 'conProfile' change_units(object, variable, unit, ...)
object |
An object of class |
variable |
A vector of variables to be changed. |
unit |
A vector with the units, corresponding to variable. |
... |
Currently not used. |
distrProfile
objectChange the units of the variables in an distrProfile
object
## S3 method for class 'distrProfile' change_units(object, variable, unit, ...)
## S3 method for class 'distrProfile' change_units(object, variable, unit, ...)
object |
An object of class |
variable |
A vector of variables to be changed. |
unit |
A vector with the units, corresponding to variable. |
... |
Currently not used. |
trackeRdata
objectChange the units of the variables in an trackeRdata
object
## S3 method for class 'trackeRdata' change_units(object, variable, unit, sport, ...)
## S3 method for class 'trackeRdata' change_units(object, variable, unit, sport, ...)
object |
An object of class |
variable |
A vector of variables whose units are to be changed. |
unit |
A vector with the units, corresponding to |
sport |
A vector of sports (among |
... |
Arguments to be passed to methods. |
trackeRdataSummary
objectChange the units of the variables in an trackeRdataSummary
object
## S3 method for class 'trackeRdataSummary' change_units(object, variable, unit, ...)
## S3 method for class 'trackeRdataSummary' change_units(object, variable, unit, ...)
object |
An object of class |
variable |
A vector of variables to be changed. Note, these are expected to be concepts like 'speed' rather than variable names like 'avgSpeed' or 'avgSpeedMoving'. |
unit |
A vector with the units, corresponding to variable. |
... |
Currently not used. |
trackeRdataZones
objectChange the units of the variables in an trackeRdataZones
object
## S3 method for class 'trackeRdataZones' change_units(object, variable, unit, ...)
## S3 method for class 'trackeRdataZones' change_units(object, variable, unit, ...)
object |
An object of class |
variable |
A vector of variables to be changed. Note, these are expected to be concepts like 'speed' rather than variable names like 'avgSpeed' or 'avgSpeedMoving'. |
unit |
A vector with the units, corresponding to variable. |
... |
Currently not used. |
trackeRthresholds
objectChange the units of the variables in an trackeRthresholds
object
## S3 method for class 'trackeRthresholds' change_units(object, variable, unit, sport, ...)
## S3 method for class 'trackeRthresholds' change_units(object, variable, unit, sport, ...)
object |
An object of class |
variable |
A vector of variables whose units are to be changed. |
unit |
A vector with the units, corresponding to |
sport |
A vector of sports (among |
... |
Arguments to be passed to methods. |
trackeRWprime
objectChange the units of the variables in an trackeRWprime
object
## S3 method for class 'trackeRWprime' change_units(object, variable, unit, ...)
## S3 method for class 'trackeRWprime' change_units(object, variable, unit, ...)
object |
An object of class |
variable |
A vector of variables to be changed. |
unit |
A vector with the units, corresponding to variable. |
... |
Currently not used. |
generate_units
Collects the units from the results of generate_units
according to a unit_reference_sport
collect_units(object, unit_reference_sport = NULL)
collect_units(object, unit_reference_sport = NULL)
object |
a |
unit_reference_sport |
The sport to inherit units from
(default is taken to be the most frequent sport in
|
trackeRdata
object.Compute a grid of breakpoints per variable from a trackeRdata
object.
compute_breaks( object, a = 1e-04, n_breaks = 9, limits = NULL, what = c("speed", "heart_rate") )
compute_breaks( object, a = 1e-04, n_breaks = 9, limits = NULL, what = c("speed", "heart_rate") )
object |
A |
a |
The levels at which quantiles will be computed are
|
n_breaks |
A scalar determining the number of breakpoints to be computed |
limits |
A list of a vectors, each specifying the lower and
upper limit for each variable to be used when computing the
grid. Default is |
what |
The variables for which a grid of breakpoints should be
computed. Defaults to |
A named list with names as in what
, with elements the grids
of breakpoints per variable.
data("runs") compute_breaks(runs, what = c("speed", "heart_rate", "altitude"))
data("runs") compute_breaks(runs, what = c("speed", "heart_rate", "altitude"))
trackeRdata
object.Compute variable limits from a trackeRdata
object.
compute_limits(object, a = 1e-04)
compute_limits(object, a = 1e-04)
object |
A |
a |
The levels at which quantiles will be computed are |
compute_limits
computes limits by finding the a
and
1 - a
quantiles for each variable in each session, and then
taking the minimum and maximum of the a
and 1 - a
,
respectively, across sessions.
Generic method for concentration profiles
concentration_profile(object, session = NULL, what = NULL, ...) concentrationProfile(object, session = NULL, what = NULL, ...)
concentration_profile(object, session = NULL, what = NULL, ...) concentrationProfile(object, session = NULL, what = NULL, ...)
object |
An object of class |
session |
A numeric vector of the sessions to be used, defaults to all sessions. |
what |
The variables for which the distribution profiles
should be generated. Defaults to all variables in |
... |
Currently not used. |
concentration_profile.distrProfile concentration_profile.trackeRdata
## Not run: ## Compute conecntration profiles from distribution profiles data('run', package = 'trackeR') dProfile <- distributionProfile(run, what = 'speed', grid = seq(0, 12.5, by = 0.05)) cProfile <- concentrationProfile(dProfile) plot(cProfile, smooth = FALSE) plot(cProfile) ## And now directly from the 'trackeRdata' object, which is a ## considerably faster if all that is needed are the concentration ## profiles cProfile <- concentrationProfile(runs, what = 'speed', limits = list(speed = c(0, 12.5))) plot(cProfile, smooth = FALSE) ridges(cProfile) plot(cProfile, smooth = TRUE) ## End(Not run)
## Not run: ## Compute conecntration profiles from distribution profiles data('run', package = 'trackeR') dProfile <- distributionProfile(run, what = 'speed', grid = seq(0, 12.5, by = 0.05)) cProfile <- concentrationProfile(dProfile) plot(cProfile, smooth = FALSE) plot(cProfile) ## And now directly from the 'trackeRdata' object, which is a ## considerably faster if all that is needed are the concentration ## profiles cProfile <- concentrationProfile(runs, what = 'speed', limits = list(speed = c(0, 12.5))) plot(cProfile, smooth = FALSE) ridges(cProfile) plot(cProfile, smooth = TRUE) ## End(Not run)
Generate training concentration profiles.
## S3 method for class 'distrProfile' concentration_profile(object, session = NULL, what = NULL, ...) ## S3 method for class 'trackeRdata' concentration_profile( object, session = NULL, what = NULL, limits = NULL, parallel = FALSE, unit_reference_sport = NULL, scale = FALSE, ... )
## S3 method for class 'distrProfile' concentration_profile(object, session = NULL, what = NULL, ...) ## S3 method for class 'trackeRdata' concentration_profile( object, session = NULL, what = NULL, limits = NULL, parallel = FALSE, unit_reference_sport = NULL, scale = FALSE, ... )
object |
An object of class |
session |
A numeric vector of the sessions to be used, defaults to all sessions. |
what |
The variables for which the distribution profiles
should be generated. Defaults to all variables in |
... |
Currently not used. |
limits |
A named list of vectors of two numbers to specify the
lower and upper limits for the variables in |
parallel |
Logical. Should computation be carried out in
parallel? Default is |
unit_reference_sport |
The sport to inherit units from
(default is taken to be the most frequent sport in
|
scale |
Logical. If |
An object of class conProfile
.
Object:
A named list with one or more components, corresponding to the
value of what
. Each component is a matrix of dimension
g
times n
, where g
is the length of the grids
set in grid
(or 200 if grid = NULL
) and n
is
the number of sessions requested in the session
argument.
Attributes:
Each conProfile
object has the following attributes:
sport
: the sports corresponding to the columns of each
list component
session_times
: the session start and end times
corresponding to the columns of each list component
unit_reference_sport
: the sport where the units have
been inherited from
operations
: a list with the operations that have been
applied to the object. See get_operations.distrProfile
limits
: The variable limits that have been used for the
computation of the concentration profiles.
units
: an object listing the units used for the
calculation of distribution profiles. These is the output of
get_units
on the corresponding
trackeRdata
object, after inheriting units from
unit_reference_sport
.
Kosmidis, I., and Passfield, L. (2015). Linking the Performance of Endurance Runners to Training and Physiological Effects via Multi-Resolution Elastic Net. ArXiv e-print arXiv:1506.01388.
Frick, H., Kosmidis, I. (2017). trackeR: Infrastructure for Running and Cycling Data from GPS-Enabled Tracking Devices in R. Journal of Statistical Software, 82(7), 1–29. doi:10.18637/jss.v082.i07
Conversion functions for distance, duration, speed, pace, power, cadence and temperature.
m2km(variable) km2m(variable) m2ft(variable) ft2m(variable) m2mi(variable) mi2m(variable) km2ft(variable) ft2km(variable) km2mi(variable) mi2km(variable) ft2mi(variable) mi2ft(variable) m2m(variable) km2km(variable) ft2ft(variable) mi2mi(variable) s2min(variable) min2s(variable) s2h(variable) h2s(variable) min2h(variable) h2min(variable) h2h(variable) min2min(variable) s2s(variable) min2min(variable) h2h(variable) degree2degree(variable) m_per_s2km_per_h(variable) km_per_h2m_per_s(variable) m_per_s2ft_per_min(variable) ft_per_min2m_per_s(variable) m_per_s2ft_per_s(variable) ft_per_s2m_per_s(variable) m_per_s2mi_per_h(variable) mi_per_h2m_per_s(variable) m_per_s2km_per_min(variable) km_per_min2m_per_s(variable) m_per_s2mi_per_min(variable) mi_per_min2m_per_s(variable) km_per_h2ft_per_min(variable) ft_per_min2km_per_h(variable) km_per_h2ft_per_s(variable) ft_per_s2km_per_h(variable) km_per_h2mi_per_h(variable) mi_per_h2km_per_h(variable) km_per_h2km_per_min(variable) km_per_min2km_per_h(variable) km_per_h2mi_per_min(variable) mi_per_min2km_per_h(variable) ft_per_min2ft_per_s(variable) ft_per_s2ft_per_min(variable) ft_per_min2mi_per_h(variable) mi_per_h2ft_per_min(variable) ft_per_min2km_per_min(variable) km_per_min2ft_per_min(variable) ft_per_min2mi_per_min(variable) mi_per_min2ft_per_min(variable) ft_per_s2mi_per_h(variable) mi_per_h2ft_per_s(variable) ft_per_s2km_per_min(variable) km_per_min2ft_per_s(variable) ft_per_s2mi_per_min(variable) mi_per_min2ft_per_s(variable) mi_per_h2km_per_min(variable) km_per_min2mi_per_h(variable) mi_per_h2mi_per_min(variable) mi_per_min2mi_per_h(variable) km_per_min2mi_per_min(variable) mi_per_min2km_per_min(variable) m_per_s2m_per_s(variable) km_per_h2km_per_h(variable) ft_per_min2ft_per_min(variable) ft_per_s2ft_per_s(variable) mi_per_h2mi_per_h(variable) km_per_min2km_per_min(variable) mi_per_min2mi_per_min(variable) m_per_s2m_per_min(variable) m_per_min2m_per_s(variable) m_per_min2m_per_min(variable) bpm2bpm(variable) s_per_m2min_per_km(variable) min_per_km2s_per_m(variable) s_per_m2min_per_mi(variable) min_per_mi2s_per_m(variable) min_per_km2min_per_mi(variable) min_per_mi2min_per_km(variable) min_per_ft2min_per_km(variable) min_per_ft2min_per_mi(variable) s_per_m2s_per_m(variable) min_per_km2min_per_km(variable) min_per_mi2min_per_mi(variable) h_per_km2min_per_km(variable) h_per_km2min_per_mi(variable) h_per_mi2min_per_km(variable) h_per_mi2min_per_mi(variable) W2kW(variable) kW2W(variable) W2W(variable) kW2kW(variable) steps_per_min2steps_per_min(variable) rev_per_min2rev_per_min(variable) steps_per_min2rev_per_min(variable) rev_per_min2steps_per_min(variable) C2F(variable) C2C(variable) F2F(variable) F2C(variable)
m2km(variable) km2m(variable) m2ft(variable) ft2m(variable) m2mi(variable) mi2m(variable) km2ft(variable) ft2km(variable) km2mi(variable) mi2km(variable) ft2mi(variable) mi2ft(variable) m2m(variable) km2km(variable) ft2ft(variable) mi2mi(variable) s2min(variable) min2s(variable) s2h(variable) h2s(variable) min2h(variable) h2min(variable) h2h(variable) min2min(variable) s2s(variable) min2min(variable) h2h(variable) degree2degree(variable) m_per_s2km_per_h(variable) km_per_h2m_per_s(variable) m_per_s2ft_per_min(variable) ft_per_min2m_per_s(variable) m_per_s2ft_per_s(variable) ft_per_s2m_per_s(variable) m_per_s2mi_per_h(variable) mi_per_h2m_per_s(variable) m_per_s2km_per_min(variable) km_per_min2m_per_s(variable) m_per_s2mi_per_min(variable) mi_per_min2m_per_s(variable) km_per_h2ft_per_min(variable) ft_per_min2km_per_h(variable) km_per_h2ft_per_s(variable) ft_per_s2km_per_h(variable) km_per_h2mi_per_h(variable) mi_per_h2km_per_h(variable) km_per_h2km_per_min(variable) km_per_min2km_per_h(variable) km_per_h2mi_per_min(variable) mi_per_min2km_per_h(variable) ft_per_min2ft_per_s(variable) ft_per_s2ft_per_min(variable) ft_per_min2mi_per_h(variable) mi_per_h2ft_per_min(variable) ft_per_min2km_per_min(variable) km_per_min2ft_per_min(variable) ft_per_min2mi_per_min(variable) mi_per_min2ft_per_min(variable) ft_per_s2mi_per_h(variable) mi_per_h2ft_per_s(variable) ft_per_s2km_per_min(variable) km_per_min2ft_per_s(variable) ft_per_s2mi_per_min(variable) mi_per_min2ft_per_s(variable) mi_per_h2km_per_min(variable) km_per_min2mi_per_h(variable) mi_per_h2mi_per_min(variable) mi_per_min2mi_per_h(variable) km_per_min2mi_per_min(variable) mi_per_min2km_per_min(variable) m_per_s2m_per_s(variable) km_per_h2km_per_h(variable) ft_per_min2ft_per_min(variable) ft_per_s2ft_per_s(variable) mi_per_h2mi_per_h(variable) km_per_min2km_per_min(variable) mi_per_min2mi_per_min(variable) m_per_s2m_per_min(variable) m_per_min2m_per_s(variable) m_per_min2m_per_min(variable) bpm2bpm(variable) s_per_m2min_per_km(variable) min_per_km2s_per_m(variable) s_per_m2min_per_mi(variable) min_per_mi2s_per_m(variable) min_per_km2min_per_mi(variable) min_per_mi2min_per_km(variable) min_per_ft2min_per_km(variable) min_per_ft2min_per_mi(variable) s_per_m2s_per_m(variable) min_per_km2min_per_km(variable) min_per_mi2min_per_mi(variable) h_per_km2min_per_km(variable) h_per_km2min_per_mi(variable) h_per_mi2min_per_km(variable) h_per_mi2min_per_mi(variable) W2kW(variable) kW2W(variable) W2W(variable) kW2kW(variable) steps_per_min2steps_per_min(variable) rev_per_min2rev_per_min(variable) steps_per_min2rev_per_min(variable) rev_per_min2steps_per_min(variable) C2F(variable) C2C(variable) F2F(variable) F2C(variable)
variable |
Variable to be converted. |
This smoother ensures a positive response that is a monotone decreasing function of x.
decreasing_smoother(x, y, k = 30, len = NULL, sp = NULL) decreasingSmoother(x, y, k = 30, len = NULL, sp = NULL)
decreasing_smoother(x, y, k = 30, len = NULL, sp = NULL) decreasingSmoother(x, y, k = 30, len = NULL, sp = NULL)
x |
The regressor passed on to the |
y |
The response passed on to the |
k |
Number of knots. |
len |
If |
sp |
A vector of smoothing parameters passed on to |
Convert distance to speed.
distance2speed(distance, time, timeunit)
distance2speed(distance, time, timeunit)
distance |
Distance in meters. |
time |
Time. |
timeunit |
Time unit in speed, e.g., "hours" for speed in *_per_h. |
Speed in meters per second.
Generate training distribution profiles.
distribution_profile( object, session = NULL, what = NULL, grid = NULL, parallel = FALSE, unit_reference_sport = NULL ) distributionProfile( object, session = NULL, what = NULL, grid = NULL, parallel = FALSE, unit_reference_sport = NULL )
distribution_profile( object, session = NULL, what = NULL, grid = NULL, parallel = FALSE, unit_reference_sport = NULL ) distributionProfile( object, session = NULL, what = NULL, grid = NULL, parallel = FALSE, unit_reference_sport = NULL )
object |
An object of class |
session |
A numeric vector of the sessions to be used, defaults to all sessions. |
what |
The variables for which the distribution profiles
should be generated. Defaults to all variables in
|
grid |
A named list containing the grid values for the
variables in |
parallel |
Logical. Should computation be carried out in
parallel? Default is |
unit_reference_sport |
The sport to inherit units from
(default is taken to be the most frequent sport in
|
An object of class distrProfile
.
Object:
A named list with one or more components, corresponding to the
value of what
. Each component is a matrix of dimension
g
times n
, where g
is the length of the grids
set in grid
(or 201 if grid = NULL
) and n
is
the number of sessions requested in the session
argument.
Attributes:
Each distrProfile
object has the following attributes:
sport
: the sports corresponding to the columns of each
list component
session_times
: the session start and end times
corresponding to the columns of each list component
unit_reference_sport
: the sport where the units have
been inherited from
operations
: a list with the operations that have been
applied to the object. See get_operations.distrProfile
limits
: The variable limits that have been used for the
computation of the distribution profiles
units
: an object listing the units used for the
calculation of distribution profiles. These is the output of
get_units
on the corresponding
trackeRdata
object, after inheriting units from
unit_reference_sport
.
Kosmidis, I., and Passfield, L. (2015). Linking the Performance of Endurance Runners to Training and Physiological Effects via Multi-Resolution Elastic Net. ArXiv e-print arXiv:1506.01388.
Frick, H., Kosmidis, I. (2017). trackeR: Infrastructure for Running and Cycling Data from GPS-Enabled Tracking Devices in R. Journal of Statistical Software, 82(7), 1–29. doi:10.18637/jss.v082.i07
data('run', package = 'trackeR') dProfile <- distribution_profile(run, what = c("speed", "cadence_running")) ## Not run: plot(dProfile, smooth = FALSE) ## End(Not run)
data('run', package = 'trackeR') dProfile <- distribution_profile(run, what = c("speed", "cadence_running")) ## Not run: plot(dProfile, smooth = FALSE) ## End(Not run)
object
Find the most frequent sport in an object
find_unit_reference_sport(object)
find_unit_reference_sport(object)
object |
any object with a |
conProfile
object for plotting with ggplot2.Fortify a conProfile
object for plotting with ggplot2.
## S3 method for class 'conProfile' fortify(model, data, melt = FALSE, ...) fortify_conProfile(model, data, melt = FALSE, ...)
## S3 method for class 'conProfile' fortify(model, data, melt = FALSE, ...) fortify_conProfile(model, data, melt = FALSE, ...)
model |
The |
data |
Ignored. |
melt |
Logical. Should the data be melted into long format instead of the default wide format? |
... |
Ignored. |
Fortify a distrProfile object for plotting with ggplot2.
## S3 method for class 'distrProfile' fortify(model, data, melt = FALSE, ...) fortify_distrProfile(model, data, melt = FALSE, ...)
## S3 method for class 'distrProfile' fortify(model, data, melt = FALSE, ...) fortify_distrProfile(model, data, melt = FALSE, ...)
model |
The |
data |
Ignored. |
melt |
Logical. Should the data be melted into long format instead of the default wide format? |
... |
Ignored. |
Fortify a trackeRdata object for plotting with ggplot2
## S3 method for class 'trackeRdata' fortify(model, data, melt = FALSE, ...) fortify_trackeRdata(model, data, melt = FALSE, ...)
## S3 method for class 'trackeRdata' fortify(model, data, melt = FALSE, ...) fortify_trackeRdata(model, data, melt = FALSE, ...)
model |
The |
data |
Ignored. |
melt |
Logical. Should the data be melted into long format instead of the default wide format? |
... |
Ignored. |
Fortify a trackeRdataSummary object for plotting with ggplot2.
## S3 method for class 'trackeRdataSummary' fortify(model, data, melt = FALSE, ...) fortify_trackeRdataSummary(model, data, melt = FALSE, ...)
## S3 method for class 'trackeRdataSummary' fortify(model, data, melt = FALSE, ...) fortify_trackeRdataSummary(model, data, melt = FALSE, ...)
model |
The |
data |
Ignored. |
melt |
Logical. Should the data be melted into long format instead of the default wide format? |
... |
Currently not used. |
Fortify a trackeRWprime object for plotting with ggplot2.
## S3 method for class 'trackeRWprime' fortify(model, data, melt = FALSE, ...) fortify_trackeRWprime(model, data, melt = FALSE, ...)
## S3 method for class 'trackeRWprime' fortify(model, data, melt = FALSE, ...) fortify_trackeRWprime(model, data, melt = FALSE, ...)
model |
The |
data |
Ignored. |
melt |
Logical. Should the data be melted into long format instead of the default wide format? |
... |
Ignored. |
Functional principal components analysis of distribution or concentration profiles.
Generic function for functional principal components analysis
## S3 method for class 'distrProfile' funPCA(object, what, nharm = 4, ...) ## S3 method for class 'conProfile' funPCA(object, what, nharm = 4, ...) funPCA(object, ...)
## S3 method for class 'distrProfile' funPCA(object, what, nharm = 4, ...) ## S3 method for class 'conProfile' funPCA(object, what, nharm = 4, ...) funPCA(object, ...)
object |
The object to which a functional principal components analysis is applied. |
what |
The variable for which the profiles should be analysed. |
nharm |
The number of principal components estimated. |
... |
Arguments to be passed to methods. |
The ...
argument is passed on to pca.fd
.
An object of class trackeRfpca
.
Ramsay JO, Silverman BW (2005). Functional Data Analysis. Springer-Verlag New York.
## Not run: data('runs', package = 'trackeR') dp <- distributionProfile(runs, what = 'speed') dp.pca <- funPCA(dp, what = 'speed', nharm = 4) ## 1st harmonic captures vast majority of the variation plot(dp.pca, harm = 1) ## time spent above speed = 0 is the characteristic distinguishing the profiles sumRuns <- summary(runs) plot(sumRuns$durationMoving, dp.pca$scores[,1]) ## End(Not run)
## Not run: data('runs', package = 'trackeR') dp <- distributionProfile(runs, what = 'speed') dp.pca <- funPCA(dp, what = 'speed', nharm = 4) ## 1st harmonic captures vast majority of the variation plot(dp.pca, harm = 1) ## time spent above speed = 0 is the characteristic distinguishing the profiles sumRuns <- summary(runs) plot(sumRuns$durationMoving, dp.pca$scores[,1]) ## End(Not run)
Coercion function for use in Golden Cheetah
GC2trackeRdata( gc, cycling = TRUE, correct_distances = FALSE, country = NULL, mask = TRUE, from_distances = FALSE, lgap = 30, lskip = 5, m = 11, silent = FALSE )
GC2trackeRdata( gc, cycling = TRUE, correct_distances = FALSE, country = NULL, mask = TRUE, from_distances = FALSE, lgap = 30, lskip = 5, m = 11, silent = FALSE )
gc |
Output of |
cycling |
Logical. Does the data stem from cycling? |
correct_distances |
Logical. Should the distances be corrected
for elevation? Default is |
country |
ISO3 country code for downloading altitude data. If
|
mask |
Logical. Passed on to
|
from_distances |
Logical. Should the speeds be calculated from the distance recordings instead of taken from the speed recordings directly? |
lgap |
Time in seconds corresponding to the minimal sampling rate. |
lskip |
Time in seconds between the last observation before a small break and the first imputed speed or the last imputed speed and the first observation after a small break. |
m |
Number of imputed observations in each small break. |
silent |
Logical. Should warnings be generated if any of the sanity checks on the data are triggered? |
Generate default thresholds.
generate_thresholds(variable, lower, upper, sport, ...) generateDefaultThresholds(variable, lower, upper, sport, ...)
generate_thresholds(variable, lower, upper, sport, ...) generateDefaultThresholds(variable, lower, upper, sport, ...)
variable |
A vector of variables with user-specified thresholds. |
lower |
A vector of lower limits corresponding to the elements of |
upper |
A vector of upper limits corresponding to the elements of |
sport |
A vector of sports (amongst |
... |
Currently not used. |
Generate and set base units.
generate_units(variable, unit, sport, ...) generateBaseUnits(variable, unit, sport, ...)
generate_units(variable, unit, sport, ...) generateBaseUnits(variable, unit, sport, ...)
variable |
A vector of variables with user-specified units. |
unit |
A vector with the user-specified units, corresponding to variable (see details). |
sport |
A vector of sports (amongst |
... |
Currently not used. |
The available units are
variables latitude
and longitude
with unit
degree
(default)
variables altitude
, distance
with unit m
(default), km
, mi
or ft
variable heart_rate
with unit bpm
(default)
variable speed
with unit m_per_s
(default),
km_per_h
, ft_per_min
, ft_per_s
or
mi_per_h
variable cadence_running
with unit
steps_per_min
(default; running only)
variable cadence_cycling
with unit rev_per_min
(default; cycling only)
variable power
with unit W
(Watt; default) or
kW
(cycling only)
variable temperature
with unit C
(Celsius;
default) or F
Note that generate_units
checks if the supplied combinations
of variable
and sport
are valid.
generate_units
will not check if any of the supplied units
are correct for the corresponding combination of variable
and sport
.
(Cumulative) Elevation gain.
get_elevation_gain( object, smooth = FALSE, cumulative = FALSE, vertical_noise = 0 )
get_elevation_gain( object, smooth = FALSE, cumulative = FALSE, vertical_noise = 0 )
object |
A (univariate) zoo object. |
smooth |
Logical. Should the elevation be smoothed? Default is
|
cumulative |
Logical. Return the cumulative elevation gain
( |
vertical_noise |
A scalar. Absolute elevation gains less that
|
The elevation gain is defined here as the difference in altitude
between two consecutive observations. If cumulative = FALSE
then the elevation gain is returned, otherwise any elevation loses
(i.e. negative elevation gain) are ignored and the cumulative
elevation gain is returned. If smooth = TRUE
then the
elevation gain will be smoothed using a spline smoother before
either returning it or computing cumulative elevation gains.
Generic function for retrieving the operation settings
get_operations(object, ...) getOperations(object, ...)
get_operations(object, ...) getOperations(object, ...)
object |
The object of which the units of measurement are retrieved. |
... |
Arguments to be passed to methods. |
conProfile
objectGet the operation settings of an conProfile
object
## S3 method for class 'conProfile' get_operations(object, ...)
## S3 method for class 'conProfile' get_operations(object, ...)
object |
An object of class |
... |
Currently not used. |
distrProfile
objectGet the operation settings of an distrProfile
object
## S3 method for class 'distrProfile' get_operations(object, ...)
## S3 method for class 'distrProfile' get_operations(object, ...)
object |
An object of class |
... |
Currently not used. |
trackeRdata
objectGet the operation settings of an trackeRdata
object
## S3 method for class 'trackeRdata' get_operations(object, ...)
## S3 method for class 'trackeRdata' get_operations(object, ...)
object |
An object of class |
... |
Currently not used. |
Generic function to subset distribution and concentration profiles
## S3 method for class 'distrProfile' get_profile(object, session = NULL, what = NULL, ...) ## S3 method for class 'conProfile' get_profile(object, session = NULL, what = NULL, ...) get_profile(object, session, what, ...)
## S3 method for class 'distrProfile' get_profile(object, session = NULL, what = NULL, ...) ## S3 method for class 'conProfile' get_profile(object, session = NULL, what = NULL, ...) get_profile(object, session, what, ...)
object |
An object of class |
session |
A numeric vector of the sessions to selected. Defaults to all sessions. |
what |
A character version of the variables to be
selected. Defaults to all variables in |
... |
Current no used. |
Extract resting period characteristics
get_resting_periods(times, session_threshold) restingPeriods(times, session_threshold)
get_resting_periods(times, session_threshold) restingPeriods(times, session_threshold)
times |
Timestamps. |
session_threshold |
The threshold in hours for the time difference between consecutive timestamps above which they are considered to belong to different training sessions. |
A list containing a dataframe with start, end, and duration for each session and the resting time between sessions, named 'sessions' and 'restingTime', respectively.
Generic function for extracting sports
## S3 method for class 'trackeRWprime' get_sport(object, ...) ## S3 method for class 'conProfile' get_sport(object, session = NULL, ...) ## S3 method for class 'distrProfile' get_sport(object, session = NULL, ...) get_sport(object, session, ...) ## S3 method for class 'trackeRdata' get_sport(object, session = NULL, ...) ## S3 method for class 'trackeRdataSummary' get_sport(object, session = NULL, ...)
## S3 method for class 'trackeRWprime' get_sport(object, ...) ## S3 method for class 'conProfile' get_sport(object, session = NULL, ...) ## S3 method for class 'distrProfile' get_sport(object, session = NULL, ...) get_sport(object, session, ...) ## S3 method for class 'trackeRdata' get_sport(object, session = NULL, ...) ## S3 method for class 'trackeRdataSummary' get_sport(object, session = NULL, ...)
object |
The object from which to extract sports. |
... |
Arguments to be passed to methods. |
session |
The sessions for which to extract sports. |
Generic function for extracting the units of measurement
get_units(object, ...) getUnits(object, ...)
get_units(object, ...) getUnits(object, ...)
object |
The object of which the units of measurement are retrieved. |
... |
Arguments to be passed to methods. |
conProfile
objectGet the units of the variables in an conProfile
object
## S3 method for class 'conProfile' get_units(object, ...)
## S3 method for class 'conProfile' get_units(object, ...)
object |
An object of class |
... |
Currently not used. |
distrProfile
objectGet the units of the variables in an distrProfile
object
## S3 method for class 'distrProfile' get_units(object, ...)
## S3 method for class 'distrProfile' get_units(object, ...)
object |
An object of class |
... |
Currently not used. |
trackeRdata
objectGet the units of the variables in an trackeRdata
object
## S3 method for class 'trackeRdata' get_units(object, ...)
## S3 method for class 'trackeRdata' get_units(object, ...)
object |
An object of class |
... |
Currently not used. |
trackeRdataSummary
objectGet the units of the variables in an trackeRdataSummary
object
## S3 method for class 'trackeRdataSummary' get_units(object, ...)
## S3 method for class 'trackeRdataSummary' get_units(object, ...)
object |
An object of class |
... |
Currently not used. |
trackeRdataZones
objectGet the units of the variables in an trackeRdataZones
object
## S3 method for class 'trackeRdataZones' get_units(object, ...)
## S3 method for class 'trackeRdataZones' get_units(object, ...)
object |
An object of class |
... |
Currently not used. |
trackeRfpca
objectGet the units of the variables in an trackeRfpca
object
## S3 method for class 'trackeRfpca' get_units(object, ...)
## S3 method for class 'trackeRfpca' get_units(object, ...)
object |
An object of class |
... |
Currently not used. |
trackeRthresholds
objectGet the units of the variables in an trackeRthresholds
object
## S3 method for class 'trackeRthresholds' get_units(object, ...)
## S3 method for class 'trackeRthresholds' get_units(object, ...)
object |
An object of class |
... |
Currently not used. |
trackeRWprime
objectGet the units of the variables in an trackeRWprime
object
## S3 method for class 'trackeRWprime' get_units(object, ...)
## S3 method for class 'trackeRWprime' get_units(object, ...)
object |
An object of class |
... |
Currently not used. |
Impute speeds of 0 during small breaks within a session.
impute_speeds( session_data, from_distances = TRUE, lgap = 30, lskip = 5, m = 11, sport = "cycling", units = NULL ) imputeSpeeds( session_data, from_distances = TRUE, lgap = 30, lskip = 5, m = 11, sport = "cycling", units = NULL )
impute_speeds( session_data, from_distances = TRUE, lgap = 30, lskip = 5, m = 11, sport = "cycling", units = NULL ) imputeSpeeds( session_data, from_distances = TRUE, lgap = 30, lskip = 5, m = 11, sport = "cycling", units = NULL )
session_data |
A multivariate |
from_distances |
Logical. Should the speeds be calculated from the distance recordings instead of taken from the speed recordings directly? |
lgap |
Time in seconds corresponding to the minimal sampling rate. |
lskip |
Time in seconds between the last observation before a small break and the first imputed speed or the last imputed speed and the first observation after a small break. |
m |
Number of imputed observations in each small break. |
sport |
What sport does |
units |
Units of measurement. |
A multivariate zoo
object with imputed observations:
0 for speed, last known position for latitude, longitude and altitude,
NA for all other variables. Distances are calculated based on speeds after imputation.
Kosmidis, I., and Passfield, L. (2015). Linking the Performance of Endurance Runners to Training and Physiological Effects via Multi-Resolution Elastic Net. ArXiv e-print arXiv:1506.01388.
Frick, H., Kosmidis, I. (2017). trackeR: Infrastructure for Running and Cycling Data from GPS-Enabled Tracking Devices in R. Journal of Statistical Software, 82(7), 1–29. doi:10.18637/jss.v082.i07
Plot the route ran/cycled during training on an interactive map. Internet connection is required to download the background map. Icons are by Maps Icons Collection https://mapicons.mapsmarker.com
leaflet_route(x, session = NULL, threshold = TRUE, ...) leafletRoute(x, session = NULL, threshold = TRUE, ...)
leaflet_route(x, session = NULL, threshold = TRUE, ...) leafletRoute(x, session = NULL, threshold = TRUE, ...)
x |
A object of class |
session |
A numeric vector of the sessions to be plotted. Defaults to all sessions. |
threshold |
Logical. Should thresholds be applied? |
... |
Additional arguments passed on to
|
## Not run: data('runs', package = 'trackeR') leafletRoute(runs, session = 23:24) ## End(Not run)
## Not run: data('runs', package = 'trackeR') leafletRoute(runs, session = 23:24) ## End(Not run)
Generic function for calculating number of sessions
## S3 method for class 'trackeRWprime' nsessions(object, ...) ## S3 method for class 'distrProfile' nsessions(object, ...) ## S3 method for class 'conProfile' nsessions(object, ...) nsessions(object, ...) ## S3 method for class 'trackeRdataSummary' nsessions(object, ...)
## S3 method for class 'trackeRWprime' nsessions(object, ...) ## S3 method for class 'distrProfile' nsessions(object, ...) ## S3 method for class 'conProfile' nsessions(object, ...) nsessions(object, ...) ## S3 method for class 'trackeRdataSummary' nsessions(object, ...)
object |
The object for which to calculate the number of sessions. |
... |
Arguments to be passed to methods. |
Plot the route ran/cycled during training onto a background map. Internet connection is required to download the background map.
plot_route( x, session = 1, zoom = NULL, speed = TRUE, threshold = TRUE, mfrow = NULL, maptype = "stamen_terrain", messaging = FALSE, ... ) plotRoute( x, session = 1, zoom = NULL, speed = TRUE, threshold = TRUE, mfrow = NULL, maptype = "stamen_terrain", messaging = FALSE, ... )
plot_route( x, session = 1, zoom = NULL, speed = TRUE, threshold = TRUE, mfrow = NULL, maptype = "stamen_terrain", messaging = FALSE, ... ) plotRoute( x, session = 1, zoom = NULL, speed = TRUE, threshold = TRUE, mfrow = NULL, maptype = "stamen_terrain", messaging = FALSE, ... )
x |
A object of class |
session |
A numeric vector of the sessions to be plotted. Defaults
to the first session, all sessions can be plotted by |
zoom |
The zoom level for the background map as passed on to
|
speed |
Logical. Should the trace be coloured according to speed? |
threshold |
Logical. Should thresholds be applied? |
mfrow |
A vector of 2 elements, number of rows and number of columns, specifying the layout for multiple sessions. |
maptype |
Passed to |
messaging |
Passed to |
... |
Additional arguments passed on to |
plot_route()
requires a a Stadia Maps API key. See register_stadiamaps
for details.
## Not run: data('runs', package = 'trackeR') plot_route(runs, session = 4, zoom = 13) plot_route(runs, session = 4, zoom = 13, maptype = "outdoors") ## multiple sessions plot_route(runs, session = c(1:4, 8:11)) ## different zoom level per panel plot_route(runs, session = 6:7, zoom = c(13, 14)) ## End(Not run)
## Not run: data('runs', package = 'trackeR') plot_route(runs, session = 4, zoom = 13) plot_route(runs, session = 4, zoom = 13, maptype = "outdoors") ## multiple sessions plot_route(runs, session = c(1:4, 8:11)) ## different zoom level per panel plot_route(runs, session = 6:7, zoom = c(13, 14)) ## End(Not run)
Plot concentration profiles.
## S3 method for class 'conProfile' plot(x, session = NULL, what = NULL, multiple = FALSE, smooth = FALSE, ...)
## S3 method for class 'conProfile' plot(x, session = NULL, what = NULL, multiple = FALSE, smooth = FALSE, ...)
x |
An object of class |
session |
A numeric vector of the sessions to be plotted, defaults to all sessions. |
what |
Which variables should be plotted? Defaults to all
variables in |
multiple |
Logical. Should all sessions be plotted in one panel? |
smooth |
Logical. Should unsmoothed profiles be smoothed before plotting? |
... |
Further arguments to be passed to
|
data('runs', package = 'trackeR') dProfile <- distributionProfile(runs, session = 1:3, what = 'speed', grid = seq(0, 12.5, by = 0.05)) cProfile <- concentrationProfile(dProfile) ## Not run: plot(cProfile, smooth = FALSE) plot(cProfile) ## End(Not run)
data('runs', package = 'trackeR') dProfile <- distributionProfile(runs, session = 1:3, what = 'speed', grid = seq(0, 12.5, by = 0.05)) cProfile <- concentrationProfile(dProfile) ## Not run: plot(cProfile, smooth = FALSE) plot(cProfile) ## End(Not run)
Plot distribution profiles.
## S3 method for class 'distrProfile' plot(x, session = NULL, what = NULL, multiple = FALSE, smooth = FALSE, ...)
## S3 method for class 'distrProfile' plot(x, session = NULL, what = NULL, multiple = FALSE, smooth = FALSE, ...)
x |
An object of class |
session |
A numeric vector of the sessions to be plotted, defaults to all sessions. |
what |
Which variables should be plotted? Defaults to all
variables in |
multiple |
Logical. Should all sessions be plotted in one panel? |
smooth |
Logical. Should unsmoothed profiles be smoothed before plotting? |
... |
Further arguments to be passed to
|
## Not run: data('runs', package = 'trackeR') dProfile <- distribution_profile(runs, session = 1:2, what = "speed", grid = seq(0, 12.5, by = 0.05)) plot(dProfile, smooth = FALSE) plot(dProfile, smooth = FALSE, multiple = TRUE) plot(dProfile, multiple = TRUE) ## End(Not run)
## Not run: data('runs', package = 'trackeR') dProfile <- distribution_profile(runs, session = 1:2, what = "speed", grid = seq(0, 12.5, by = 0.05)) plot(dProfile, smooth = FALSE) plot(dProfile, smooth = FALSE, multiple = TRUE) plot(dProfile, multiple = TRUE) ## End(Not run)
Plot training sessions in form of trackeRdata objects
## S3 method for class 'trackeRdata' plot( x, session = NULL, what = c("pace", "heart_rate"), threshold = TRUE, smooth = FALSE, trend = TRUE, dates = TRUE, unit_reference_sport = NULL, moving_threshold = NULL, ... )
## S3 method for class 'trackeRdata' plot( x, session = NULL, what = c("pace", "heart_rate"), threshold = TRUE, smooth = FALSE, trend = TRUE, dates = TRUE, unit_reference_sport = NULL, moving_threshold = NULL, ... )
x |
An object of class |
session |
A numeric vector of the sessions to be plotted, defaults to all sessions. |
what |
Which variables should be plotted? A vector with at least one of |
threshold |
Logical. Should thresholds be applied? |
smooth |
Logical. Should the data be smoothed? |
trend |
Logical. Should a smooth trend be plotted? |
dates |
Logical. Should the date of the session be used in the panel header? |
unit_reference_sport |
The sport to inherit units from
(default is taken to be the most frequent sport in
|
moving_threshold |
A named vector of 3 speeds to be used for
thresholding pace, given in the unit of the speed measurements
in |
... |
Further arguments to be passed to
|
Note that a threshold is always applied to the pace. This (upper) threshold corresponds to a speed of 1.4 meters per second, the preferred walking speed of humans. The lower threshold is 0.
The units for the variables match those of the sport specified by
unit_reference_sport
.
trackeRdata
## Not run: data('runs', package = 'trackeR') ## plot heart rate and pace for the first 3 sessions plot(runs, session = 1:3) ## plot raw speed data for session 4 plot(runs, session = 4, what = "speed", threshold = FALSE, smooth = FALSE) ## threshold speed variable plot(runs, session = 4, what = "speed", threshold = TRUE, smooth = FALSE, variable = "speed", lower = 0, upper = 10) ## and smooth (thresholding with default values) plot(runs, session = 4, what = "speed", threshold = TRUE, smooth = TRUE, width = 15, parallel = FALSE) #' ## Speed and elevation gain plot(runs, session = 2:10, what = c("speed", "cumulative_elevation_gain"), trend = FALSE) ## End(Not run)
## Not run: data('runs', package = 'trackeR') ## plot heart rate and pace for the first 3 sessions plot(runs, session = 1:3) ## plot raw speed data for session 4 plot(runs, session = 4, what = "speed", threshold = FALSE, smooth = FALSE) ## threshold speed variable plot(runs, session = 4, what = "speed", threshold = TRUE, smooth = FALSE, variable = "speed", lower = 0, upper = 10) ## and smooth (thresholding with default values) plot(runs, session = 4, what = "speed", threshold = TRUE, smooth = TRUE, width = 15, parallel = FALSE) #' ## Speed and elevation gain plot(runs, session = 2:10, what = c("speed", "cumulative_elevation_gain"), trend = FALSE) ## End(Not run)
trackeRdataSummary
.Plot an object of class trackeRdataSummary
.
## S3 method for class 'trackeRdataSummary' plot(x, date = TRUE, what = NULL, group = NULL, trend = TRUE, ...)
## S3 method for class 'trackeRdataSummary' plot(x, date = TRUE, what = NULL, group = NULL, trend = TRUE, ...)
x |
An object of class |
date |
Should the date or the session number be used on the abscissa? |
what |
Name of variables which should be plotted. Default is all. A vector with at least one of |
group |
Which group of variables should be plotted? This can either be
|
trend |
Should a smooth trend be plotted? |
... |
Currently not used. |
## Not run: data('runs', package = 'trackeR') runSummary <- summary(runs) plot(runSummary) plot(runSummary, date = FALSE, group = 'total', what = c('distance', 'duration', 'avgSpeed')) ## End(Not run)
## Not run: data('runs', package = 'trackeR') runSummary <- summary(runs) plot(runSummary) plot(runSummary, date = FALSE, group = 'total', what = c('distance', 'duration', 'avgSpeed')) ## End(Not run)
Plot training zones.
## S3 method for class 'trackeRdataZones' plot(x, percent = TRUE, ...)
## S3 method for class 'trackeRdataZones' plot(x, percent = TRUE, ...)
x |
An object of class |
percent |
Logical. Should the relative or absolute times spent training in the different zones be plotted? |
... |
Currently not used. |
## Not run: data('run', package = 'trackeR') runZones <- zones(run, what = 'speed', breaks = c(0, 2:6, 12.5)) plot(runZones, percent = FALSE) ## End(Not run)
## Not run: data('run', package = 'trackeR') runZones <- zones(run, what = 'speed', breaks = c(0, 2:6, 12.5)) plot(runZones, percent = FALSE) ## End(Not run)
Plot function for functional principal components analysis of distribution and concentration profiles.
## S3 method for class 'trackeRfpca' plot(x, harm = NULL, expand = NULL, pointplot = TRUE, ...)
## S3 method for class 'trackeRfpca' plot(x, harm = NULL, expand = NULL, pointplot = TRUE, ...)
x |
An object of class |
harm |
A numerical vector of the harmonics to be plotted. Defaults to all harmonics. |
expand |
The factor used to generate suitable multiples of the harmonics.
If |
pointplot |
Should the harmonics be plotted with |
... |
Currently not used. |
Ramsay JO, Silverman BW (2005). Functional Data Analysis. Springer-Verlag New York.
## Not run: data('runs', package = 'trackeR') dp <- distributionProfile(runs, what = 'speed') dp.pca <- funPCA(dp, what = 'speed', nharm = 4) ## 1st harmonic captures vast majority of the variation plot(dp.pca) plot(dp.pca, harm = 1, pointplot = FALSE) ## End(Not run)
## Not run: data('runs', package = 'trackeR') dp <- distributionProfile(runs, what = 'speed') dp.pca <- funPCA(dp, what = 'speed', nharm = 4) ## 1st harmonic captures vast majority of the variation plot(dp.pca) plot(dp.pca, harm = 1, pointplot = FALSE) ## End(Not run)
Plot W'.
## S3 method for class 'trackeRWprime' plot(x, session = NULL, dates = TRUE, scaled = TRUE, ...)
## S3 method for class 'trackeRWprime' plot(x, session = NULL, dates = TRUE, scaled = TRUE, ...)
x |
An object of class |
session |
A numeric vector of the sessions to be plotted, defaults to all sessions. |
dates |
Logical. Should the date of the session be used in the panel header? |
scaled |
Logical. Should the W' be scaled to the movement variable (power or speed) which is then plotted in the background? |
... |
Currently not used. |
## Not run: data('runs', package = 'trackeR') wexp <- Wprime(runs, session = 1:3, cp = 4, version = '2012') plot(wexp, session = 1:2) ## End(Not run)
## Not run: data('runs', package = 'trackeR') wexp <- Wprime(runs, session = 1:3, cp = 4, version = '2012') plot(wexp, session = 1:2) ## End(Not run)
data.frame
for use in
leaflet_route
and plot_route
Prepare a data.frame
for use in
leaflet_route
and plot_route
prepare_route(x, session = 1, threshold = TRUE, ...)
prepare_route(x, session = 1, threshold = TRUE, ...)
x |
a |
session |
which session to prepare the
|
threshold |
if |
... |
Additional arguments to be passed to
|
To be used internally in mapping function and rarely by the user.
A data.frame
with variables longitude
,
latitude
, speed
, SessionID
, longitude0
,
longitude1
, latitude0
, latitude1
. The
observations are ordered according to the timestamp they have in
x
. A suffix of 0 indicates 'start' and a suffix of 1
indicates 'end' at any given observation.
Returns 'pretty' units for use for plotting or printing
prettifyUnit(unit) prettifyUnits(unit)
prettifyUnit(unit) prettifyUnits(unit)
unit |
a unit as recorded in the |
prettifyUnits
is the vectorized version of prettifyUnit
prettifyUnit("m_per_s") prettifyUnit("rev_per_min") prettifyUnits(c("rev_per_min", "ft_per_min"))
prettifyUnit("m_per_s") prettifyUnit("rev_per_min") prettifyUnits(c("rev_per_min", "ft_per_min"))
print
method for trackeRdata
objectsprint
method for trackeRdata
objects
## S3 method for class 'trackeRdata' print(x, duration_unit = "h", digits = 2, ...)
## S3 method for class 'trackeRdata' print(x, duration_unit = "h", digits = 2, ...)
x |
An object of class |
duration_unit |
The unit of duration in the resulting output. Default is |
digits |
Number of digits to be printed. |
... |
Currently not used; only for compatibility with generic |
The print method returns training coverage, number of sessions and
total training duration from the data in the
trackeRdata
object.
Print method for session summaries.
## S3 method for class 'trackeRdataSummary' print(x, ..., digits = 2)
## S3 method for class 'trackeRdataSummary' print(x, ..., digits = 2)
x |
An object of class |
... |
Not used, for compatibility with generic summary method only. |
digits |
Number of digits to be printed. |
Transform distribution and concentration profiles to functional data objects of class fd.
profile2fd(object, what, ...)
profile2fd(object, what, ...)
object |
An object of class |
what |
The variable for which the profiles should be transformed to a functional data object. |
... |
Additional arguments passed on to |
An object of class fd
.
## Not run: library('fda') data('runs', package = 'trackeR') dp <- distributionProfile(runs, what = 'speed') dpFun <- profile2fd(dp, what = 'speed', fdnames = list('speed', 'sessions', 'time above threshold')) dp.pca <- pca.fd(dpFun, nharm = 4) ## 1st harmonic captures vast majority of the variation dp.pca$varprop ## time spent above speed = 0 is the characteristic distinguishing the profiles plot(dp.pca, harm = 1) sumRuns <- summary(runs) plot(sumRuns$durationMoving, dp.pca$scores[,1]) ## End(Not run)
## Not run: library('fda') data('runs', package = 'trackeR') dp <- distributionProfile(runs, what = 'speed') dpFun <- profile2fd(dp, what = 'speed', fdnames = list('speed', 'sessions', 'time above threshold')) dp.pca <- pca.fd(dpFun, nharm = 4) ## 1st harmonic captures vast majority of the variation dp.pca$varprop ## time spent above speed = 0 is the characteristic distinguishing the profiles plot(dp.pca, harm = 1) sumRuns <- summary(runs) plot(sumRuns$durationMoving, dp.pca$scores[,1]) ## End(Not run)
Read a GPS container file.
read_container( file, type = c("tcx", "gpx", "db3", "json"), table = "gps_data", timezone = "", session_threshold = 2, correct_distances = FALSE, smooth_elevation_gain = TRUE, country = NULL, mask = TRUE, from_distances = NULL, speedunit = NULL, distanceunit = NULL, sport = NULL, lgap = 30, lskip = 5, m = 11, silent = FALSE ) readContainer( file, type = c("tcx", "gpx", "db3", "json"), table = "gps_data", timezone = "", session_threshold = 2, correct_distances = FALSE, smooth_elevation_gain = TRUE, country = NULL, mask = TRUE, from_distances = NULL, speedunit = NULL, distanceunit = NULL, sport = NULL, lgap = 30, lskip = 5, m = 11, silent = FALSE )
read_container( file, type = c("tcx", "gpx", "db3", "json"), table = "gps_data", timezone = "", session_threshold = 2, correct_distances = FALSE, smooth_elevation_gain = TRUE, country = NULL, mask = TRUE, from_distances = NULL, speedunit = NULL, distanceunit = NULL, sport = NULL, lgap = 30, lskip = 5, m = 11, silent = FALSE ) readContainer( file, type = c("tcx", "gpx", "db3", "json"), table = "gps_data", timezone = "", session_threshold = 2, correct_distances = FALSE, smooth_elevation_gain = TRUE, country = NULL, mask = TRUE, from_distances = NULL, speedunit = NULL, distanceunit = NULL, sport = NULL, lgap = 30, lskip = 5, m = 11, silent = FALSE )
file |
The path to a tcx, gpx, json or db3 file. Compressed versions (gz, bz2, xz, zip) of tcx, gpx, and json files are directly supported. |
type |
The type of the GPS container file. Supported so far
are |
table |
The name of the table in the database if |
timezone |
The timezone of the observations as passed on to
|
session_threshold |
The threshold in hours for the time difference between consecutive timestamps above which they are considered to belong to different training sessions. |
correct_distances |
Logical. Should the distances be corrected
for elevation? Default is |
smooth_elevation_gain |
Logical. Should the elevation gain be
smoothed before computing elevation gain? Default
is |
country |
ISO3 country code for downloading altitude data. If
|
mask |
Logical. Passed on to
|
from_distances |
Logical. Should the speeds be calculated from
the distance recordings instead of taken from the speed
recordings directly. Defaults to |
speedunit |
Character string indicating the measurement unit
of the speeds in the container file to be converted into meters
per second. Default is |
distanceunit |
Character string indicating the measurement
unit of the distance in the container file to be converted into
meters. Default is |
sport |
What sport does |
lgap |
Time in seconds corresponding to the minimal sampling rate. |
lskip |
Time in seconds between the last observation before a small break and the first imputed speed or the last imputed speed and the first observation after a small break. |
m |
Number of imputed observations in each small break. |
silent |
Logical. Should warnings be generated if any of the sanity checks on the data are triggered? |
Available options for speedunit
currently are
km_per_h
, m_per_s
, mi_per_h
,
ft_per_min
and ft_per_s
. Available options for
distanceunit
currently are km
, m
,
mi
and ft
.
read_container
try to identify the sport from the data in
the container file. If that fails, then an attempt is made to guess
the sport from keywords in the filename. If identification is not
possible then an error is returned from
trackeRdata
. To avoid that error, and if the sport is
known, append an appropriate keyword to the filename (e.g. 'ride',
'swim', 'run'). This should fix the error.
An object of class trackeRdata
.
trackeRdata
, readTCX
, readDB3
, readJSON
filepath <- system.file("extdata/tcx", "2013-06-08-090442.TCX.gz", package = "trackeR") run <- read_container(filepath, type = "tcx", timezone = "GMT")
filepath <- system.file("extdata/tcx", "2013-06-08-090442.TCX.gz", package = "trackeR") run <- read_container(filepath, type = "tcx", timezone = "GMT")
Read all supported container files from a supplied directory
read_directory( directory, aggregate = FALSE, table = "gps_data", timezone = "", session_threshold = 2, smooth_elevation_gain = TRUE, correct_distances = FALSE, country = NULL, mask = TRUE, from_distances = NULL, speedunit = list(tcx = "m_per_s", gpx = "km_per_h", db3 = "km_per_h", json = "km_per_h"), distanceunit = list(tcx = "m", gpx = "km", db3 = "km", json = "km"), sport = NULL, lgap = 30, lskip = 5, m = 11, silent = FALSE, parallel = FALSE, verbose = TRUE ) readDirectory( directory, aggregate = FALSE, table = "gps_data", timezone = "", session_threshold = 2, smooth_elevation_gain = TRUE, correct_distances = FALSE, country = NULL, mask = TRUE, from_distances = NULL, speedunit = list(tcx = "m_per_s", gpx = "km_per_h", db3 = "km_per_h", json = "km_per_h"), distanceunit = list(tcx = "m", gpx = "km", db3 = "km", json = "km"), sport = NULL, lgap = 30, lskip = 5, m = 11, silent = FALSE, parallel = FALSE, verbose = TRUE )
read_directory( directory, aggregate = FALSE, table = "gps_data", timezone = "", session_threshold = 2, smooth_elevation_gain = TRUE, correct_distances = FALSE, country = NULL, mask = TRUE, from_distances = NULL, speedunit = list(tcx = "m_per_s", gpx = "km_per_h", db3 = "km_per_h", json = "km_per_h"), distanceunit = list(tcx = "m", gpx = "km", db3 = "km", json = "km"), sport = NULL, lgap = 30, lskip = 5, m = 11, silent = FALSE, parallel = FALSE, verbose = TRUE ) readDirectory( directory, aggregate = FALSE, table = "gps_data", timezone = "", session_threshold = 2, smooth_elevation_gain = TRUE, correct_distances = FALSE, country = NULL, mask = TRUE, from_distances = NULL, speedunit = list(tcx = "m_per_s", gpx = "km_per_h", db3 = "km_per_h", json = "km_per_h"), distanceunit = list(tcx = "m", gpx = "km", db3 = "km", json = "km"), sport = NULL, lgap = 30, lskip = 5, m = 11, silent = FALSE, parallel = FALSE, verbose = TRUE )
directory |
The path to the directory. |
aggregate |
Logical. Aggregate data from different files to
the same session if observations are less then
|
table |
The name of the table in the database for db3 files. |
timezone |
The timezone of the observations as passed on to
|
session_threshold |
The threshold in hours for the time difference between consecutive timestamps above which they are considered to belong to different training sessions. |
smooth_elevation_gain |
Logical. Should the elevation gain be
smoothed before computing elevation gain? Default
is |
correct_distances |
Logical. Should the distances be corrected
for elevation? Default is |
country |
ISO3 country code for downloading altitude data. If
|
mask |
Logical. Passed on to
|
from_distances |
Logical. Should the speeds be calculated from
the distance recordings instead of taken from the speed
recordings directly. Defaults to |
speedunit |
Character string indicating the measurement unit
of the speeds in the container file to be converted into meters
per second. Default is |
distanceunit |
Character string indicating the measurement
unit of the distance in the container file to be converted into
meters. Default is |
sport |
What sport do the files in |
lgap |
Time in seconds corresponding to the minimal sampling rate. |
lskip |
Time in seconds between the last observation before a small break and the first imputed speed or the last imputed speed and the first observation after a small break. |
m |
Number of imputed observations in each small break. |
silent |
Logical. Should warnings be generated if any of the sanity checks on the data are triggered? |
parallel |
Logical. Should reading be carried out in parallel?
If |
verbose |
Logical. Should progress reports be printed? |
Available options for speedunit
currently are
km_per_h
, m_per_s
, mi_per_h
,
ft_per_min
and ft_per_s
. Available options for
distanceunit
currently are km
, m
,
mi
and ft
.
If aggregate = TRUE
, then if sport = NULL
the
sport in all sessions is determined by the first file read with
a sport specification; else if sport
is one of the other
valid options it determines the sport for all sessions.
An object of class trackeRdata
.
trackeRdata
, readTCX
, readDB3
, readJSON
## Not run: filepath <- system.file("extdata/gpx", package = "trackeR") gpx_files <- read_directory(filepath) ## End(Not run)
## Not run: filepath <- system.file("extdata/gpx", package = "trackeR") gpx_files <- read_directory(filepath) ## End(Not run)
Read a training file in tcx, gpx, db3 or Golden Cheetah's JSON format
readTCX(file, timezone = "", speedunit = "m_per_s", distanceunit = "m", ...) readGPX(file, timezone = "", speedunit = "km_per_h", distanceunit = "km", ...) readDB3( file, timezone = "", table = "gps_data", speedunit = "km_per_h", distanceunit = "km", ... ) readJSON(file, timezone = "", speedunit = "km_per_h", distanceunit = "km", ...)
readTCX(file, timezone = "", speedunit = "m_per_s", distanceunit = "m", ...) readGPX(file, timezone = "", speedunit = "km_per_h", distanceunit = "km", ...) readDB3( file, timezone = "", table = "gps_data", speedunit = "km_per_h", distanceunit = "km", ... ) readJSON(file, timezone = "", speedunit = "km_per_h", distanceunit = "km", ...)
file |
The path to a tcx, gpx, json or db3 file. Compressed versions (gz, bz2, xz, zip) of tcx, gpx, and json files are directly supported. |
timezone |
The timezone of the observations as passed on to
|
speedunit |
Character string indicating the measurement unit of the speeds in the container file to be converted into meters per second. See Details. |
distanceunit |
Character string indicating the measurement unit of the distance in the container file to be converted into meters. See Details. |
... |
Currently not used. |
table |
Character string indicating the name of the table with the GPS data in the db3 container file. |
Available options for speedunit
currently are
km_per_h
, m_per_s
, mi_per_h
,
ft_per_min
and ft_per_s
. The default is
m_per_s
for TCX files and km_per_h
for db3 and
Golden Cheetah's json files. Available options for
distanceunit
currently are km
, m
,
mi
and ft
. The default is m
for TCX and
km
for gpx, db3 and Golden Cheetah's json files.
readTCX
, readGPX
, readGPX
and readDB3
,
try to identify the sport from the data in the container file. If
that fails, then an attempt is made to guess the sport from
keywords in the filename. If identification is not possible then
the file
attribute of the returned object has value
NA
.
Reading Golden Cheetah's JSON files is experimental.
## read raw data filepath <- system.file("extdata/tcx", "2013-06-08-090442.TCX.gz", package = "trackeR") run0 <- readTCX(file = filepath, timezone = "GMT") ## turn into trackeRdata object units0 <- generate_units() run0 <- trackeRdata(run0, units = units0) ## alternatively ## Not run: run0 <- read_container(filepath, type = "tcx", timezone = "GMT") ## End(Not run)
## read raw data filepath <- system.file("extdata/tcx", "2013-06-08-090442.TCX.gz", package = "trackeR") run0 <- readTCX(file = filepath, timezone = "GMT") ## turn into trackeRdata object units0 <- generate_units() run0 <- trackeRdata(run0, units = units0) ## alternatively ## Not run: run0 <- read_container(filepath, type = "tcx", timezone = "GMT") ## End(Not run)
Generic function for ridgeline plots
ridges(x, ...)
ridges(x, ...)
x |
An object of class |
... |
Arguments to be passed to methods. |
ridges.trackeRdata ridges.conProfile ridges.distrProfile
distrProfile
objectsRidgeline plots for distrProfile
objects
## S3 method for class 'conProfile' ridges(x, session = NULL, what = NULL, smooth = FALSE, ...)
## S3 method for class 'conProfile' ridges(x, session = NULL, what = NULL, smooth = FALSE, ...)
x |
An object of class |
session |
A numeric vector of the sessions to be plotted, defaults to all sessions. |
what |
Which variables should be plotted? Defaults to all
variables in |
smooth |
Logical. Should unsmoothed profiles be smoothed before plotting? |
... |
Further arguments to be passed to
|
## Not run: data('runs', package = 'trackeR') dProfile <- distributionProfile(runs, what = c('speed', 'heart_rate')) cProfile <- concentrationProfile(dProfile) ridges(cProfile, what = "speed") ridges(cProfile, what = "heart_rate") ## End(Not run)
## Not run: data('runs', package = 'trackeR') dProfile <- distributionProfile(runs, what = c('speed', 'heart_rate')) cProfile <- concentrationProfile(dProfile) ridges(cProfile, what = "speed") ridges(cProfile, what = "heart_rate") ## End(Not run)
distrProfile
objectsRidgeline plots for distrProfile
objects
## S3 method for class 'distrProfile' ridges(x, session = NULL, what = NULL, smooth = FALSE, ...)
## S3 method for class 'distrProfile' ridges(x, session = NULL, what = NULL, smooth = FALSE, ...)
x |
An object of class |
session |
A numeric vector of the sessions to be plotted, defaults to all sessions. |
what |
Which variables should be plotted? Defaults to all
variables in |
smooth |
Logical. Should unsmoothed profiles be smoothed before plotting? |
... |
Further arguments to be passed to
|
## Not run: data('runs', package = 'trackeR') dProfile <- distribution_profile(runs, what = c("speed", "heart_rate")) ridges(dProfile) ## End(Not run)
## Not run: data('runs', package = 'trackeR') dProfile <- distribution_profile(runs, what = c("speed", "heart_rate")) ridges(dProfile) ## End(Not run)
trackeRdata
objectsRidgeline plots for trackeRdata
objects
## S3 method for class 'trackeRdata' ridges(x, session = NULL, what = "speed", smooth = TRUE, ...)
## S3 method for class 'trackeRdata' ridges(x, session = NULL, what = "speed", smooth = TRUE, ...)
x |
A |
session |
A numeric vector of the sessions to be used, defaults to all sessions. |
what |
The variables for which the distribution profiles
should be generated. Defaults to all variables in
|
smooth |
Logical. Should the concentration profiles be smoothed before plotting? |
... |
Currently not used. |
## Not run: data('runs', package = 'trackeR') ridges(runs) ## End(Not run)
## Not run: data('runs', package = 'trackeR') ridges(runs) ## End(Not run)
Training session.
run
run
A trackeRdata
object containing one running training session.
Training sessions.
runs
runs
A trackeRdata
object containing 33 running training sessions.
Heart rate measurements of 0 are set to NA, assuming the athlete is alive. Observations with missing or duplicated time stamps are removed.
sanity_checks(dat, silent)
sanity_checks(dat, silent)
dat |
Data set to be cleaned up. |
silent |
Logical. Should warnings be generated if any of the sanity checks on the data are triggered? |
Generic function for scaling
scaled(object, ...)
scaled(object, ...)
object |
The object to be scaled. |
... |
Arguments to be passed to methods. |
Scale the distribution profile relative to its maximum value.
## S3 method for class 'distrProfile' scaled(object, session = NULL, what = NULL, ...)
## S3 method for class 'distrProfile' scaled(object, session = NULL, what = NULL, ...)
object |
An object of class |
session |
A numeric vector of the sessions to be selected and scaled. Defaults to all sessions. |
what |
A character version of the variables to be selected and
scaled. Defaults to all variables in |
... |
Currently not used. |
Generic function for calculating session durations
session_duration(object, session, duration_unit, ...) ## S3 method for class 'trackeRdata' session_duration(object, session = NULL, duration_unit = "h", ...) ## S3 method for class 'trackeRdataSummary' session_duration(object, session = NULL, ...)
session_duration(object, session, duration_unit, ...) ## S3 method for class 'trackeRdata' session_duration(object, session = NULL, duration_unit = "h", ...) ## S3 method for class 'trackeRdataSummary' session_duration(object, session = NULL, ...)
object |
The object for which to calculate session durations. |
session |
The sessions for which to extract sports. |
duration_unit |
The unit of duration. |
... |
Arguments to be passed to methods. |
The times units will be inherited from object
.
Generic function for calculating session times
session_times(object, session, duration_unit, ...) ## S3 method for class 'trackeRdata' session_times(object, session = NULL, ...) ## S3 method for class 'trackeRdataSummary' session_times(object, session = NULL, ...)
session_times(object, session, duration_unit, ...) ## S3 method for class 'trackeRdata' session_times(object, session = NULL, ...) ## S3 method for class 'trackeRdataSummary' session_times(object, session = NULL, ...)
object |
The object for which to calculate session start and end times. |
session |
The sessions for which to extract sports. |
duration_unit |
The unit durations should be returned. |
... |
Arguments to be passed to methods. |
Generic function for smoothing
smoother(object, ...)
smoother(object, ...)
object |
The object to be smoothed. |
... |
Arguments to be passed to methods. |
smoother.distrProfile
. Typically used to construct a
control argument for smoother.distrProfile
.Auxiliary function for
smoother.distrProfile
. Typically used to construct a
control argument for smoother.distrProfile
.
smoother_control.distrProfile(k = 30, sp = NULL, parallel = FALSE) smootherControl.distrProfile(k = 30, sp = NULL, parallel = FALSE)
smoother_control.distrProfile(k = 30, sp = NULL, parallel = FALSE) smootherControl.distrProfile(k = 30, sp = NULL, parallel = FALSE)
k |
Number of knots. |
sp |
A vector of smoothing parameters passed on to |
parallel |
Logical. Should computation be carried out in parallel? |
smoother.trackeRdata
. Typically used to construct
a control argument for smoother.trackeRdata
.Auxiliary function for smoother.trackeRdata
. Typically used to construct
a control argument for smoother.trackeRdata
.
smoother_control.trackeRdata( fun = "mean", width = 10, parallel = FALSE, what = c("speed", "heart_rate"), nsessions = NA, ... ) smootherControl.trackeRdata( fun = "mean", width = 10, parallel = FALSE, what = c("speed", "heart_rate"), nsessions = NA, ... )
smoother_control.trackeRdata( fun = "mean", width = 10, parallel = FALSE, what = c("speed", "heart_rate"), nsessions = NA, ... ) smootherControl.trackeRdata( fun = "mean", width = 10, parallel = FALSE, what = c("speed", "heart_rate"), nsessions = NA, ... )
fun |
The name of the function to be matched and used to aggregate/smooth the data. |
width |
The width of the window in which the raw observations
get aggregated via function |
parallel |
Logical. Should computation be carried out in
parallel? If |
what |
Vector of the names of the variables which should be smoothed. |
nsessions |
Vector containing the number of session. Default corresponds to all sessions belonging to the same group. Used only internally. |
... |
Currently not used. |
To ensure positivity of the smoothed concentration profiles, the concentration profiles are transformed to distribution profiles before smoothing. The smoothed distribution profiles are then transformed to concentration profiles.
## S3 method for class 'conProfile' smoother(object, session = NULL, what = NULL, control = list(...), ...)
## S3 method for class 'conProfile' smoother(object, session = NULL, what = NULL, control = list(...), ...)
object |
An object of class |
session |
A numeric vector of the sessions to be selected and smoothed. Defaults to all sessions. |
what |
A character version of the variables to be selected and
smoothed. Defaults to all variables in |
control |
A list of parameters for controlling the smoothing
process. This is passed to
|
... |
Arguments to be used to form the default |
The distribution profiles are smoothed using a shape constrained additive model with Poisson responses to ensure that the smoothed distribution profile is positive and monotone decreasing.
## S3 method for class 'distrProfile' smoother(object, session = NULL, what = NULL, control = list(...), ...)
## S3 method for class 'distrProfile' smoother(object, session = NULL, what = NULL, control = list(...), ...)
object |
An object of class |
session |
A numeric vector of the sessions to be selected and smoothed. Defaults to all sessions. |
what |
A character version of the variables to be selected and
smoothed. Defaults to all variables in |
control |
A list of parameters for controlling the smoothing
process. This is passed to
|
... |
Arguments to be used to form the default |
Kosmidis, I., and Passfield, L. (2015). Linking the Performance of Endurance Runners to Training and Physiological Effects via Multi-Resolution Elastic Net. ArXiv e-print arXiv:1506.01388.
Pya, N. and Wood S. (2015). Shape Constrained Additive Models. Statistics and Computing, 25(3), 543–559. Frick, H.,
Kosmidis, I. (2017). trackeR: Infrastructure for Running and Cycling Data from GPS-Enabled Tracking Devices in R. Journal of Statistical Software, 82(7), 1–29. doi:10.18637/jss.v082.i07
trackeRdata
objects.Smoother for trackeRdata
objects.
## S3 method for class 'trackeRdata' smoother(object, session = NULL, control = list(...), ...)
## S3 method for class 'trackeRdata' smoother(object, session = NULL, control = list(...), ...)
object |
An object of class |
session |
The sessions to be smoothed. Default is all sessions. |
control |
A list of parameters for controlling the smoothing
process. This is passed to |
... |
Arguments to be used to form the default |
An object of class trackeRdata
.
## Not run: data('run', package = 'trackeR') ## unsmoothed speeds plot(run, smooth = FALSE) ## default smoothing plot(run, smooth = TRUE) ## smoothed with some non-default options runS <- smoother(run, fun = 'median', width = 20, what = 'speed') plot(runS, smooth = FALSE) ## End(Not run)
## Not run: data('run', package = 'trackeR') ## unsmoothed speeds plot(run, smooth = FALSE) ## default smoothing plot(run, smooth = TRUE) ## smoothed with some non-default options runS <- smoother(run, fun = 'median', width = 20, what = 'speed') plot(runS, smooth = FALSE) ## End(Not run)
trackeRdata
objectsSort the sessions trackeRdata
objects into ascending
or descending order according to the first session timestamp.
## S3 method for class 'trackeRdata' sort(x, decreasing = FALSE, ...)
## S3 method for class 'trackeRdata' sort(x, decreasing = FALSE, ...)
x |
A |
decreasing |
Logical. Should the objects be sorted in increasing or decreasing order? |
... |
Currently not used. |
Convert speed to distance.
speed2distance(speed, time, timeunit, cumulative = TRUE)
speed2distance(speed, time, timeunit, cumulative = TRUE)
speed |
Speed in meters per second. |
time |
Time. |
timeunit |
Time unit in speed, e.g., "hours" for speed in *_per_h. |
cumulative |
Logical. Should the cumulative distances be returned? |
Distance in meters.
Summary of training sessions
## S3 method for class 'trackeRdata' summary( object, session = NULL, moving_threshold = NULL, unit_reference_sport = NULL, ... )
## S3 method for class 'trackeRdata' summary( object, session = NULL, moving_threshold = NULL, unit_reference_sport = NULL, ... )
object |
An object of class |
session |
A numeric vector of the sessions to be summarised, defaults to all sessions. |
moving_threshold |
A named vector of 3 speeds above which an
athlete is considered moving, given in the unit of the speed
measurements in |
unit_reference_sport |
The sport to inherit units from
(default is taken to be the most frequent sport in
|
... |
Currently not used. |
The default speed thresholds are 1 m/s for running (3.6 km/h; slow walking), 2 m/s for cycling (7.2 km/h) for cycling and 0.5 m/s (1.8km/h) for swimming. For reference, the preferred walking speed for humans is around 1.4 m/s (Bohannon, 1997).
The units for the computed summaries match those of the sport
specified by unit_reference_sport
.
If object
has thresholds then the thresholds that match
those of the sport specified by unit_reference_sport
are
applied to the respective summaries.
An object of class trackeRdataSummary
.
Bohannon RW (1997). 'Comfortable and Maximum Walking Speed of Adults Aged 20–79 Years: Reference Values and Determinants.' Age and Ageing, 26(1), 15–19. doi: 10.1093/ageing/26.1.15.
data('runs', package = 'trackeR') runSummary <- summary(runs, session = 1:2) ## print summary runSummary print(runSummary, digits = 3) ## Not run: ## change units change_units(runSummary, variable = 'speed', unit = 'km_per_h') ## plot summary runSummaryFull <- summary(runs) plot(runSummaryFull) plot(runSummaryFull, group = c('total', 'moving'), what = c('avgSpeed', 'distance', 'duration', 'avgHeartRate', "total_elevation_gain")) ## End(Not run)
data('runs', package = 'trackeR') runSummary <- summary(runs, session = 1:2) ## print summary runSummary print(runSummary, digits = 3) ## Not run: ## change units change_units(runSummary, variable = 'speed', unit = 'km_per_h') ## plot summary runSummaryFull <- summary(runs) plot(runSummaryFull) plot(runSummaryFull, group = c('total', 'moving'), what = c('avgSpeed', 'distance', 'duration', 'avgHeartRate', "total_elevation_gain")) ## End(Not run)
trackeRdata
objectsThresholding for variables in trackeRdata
objects
## S3 method for class 'trackeRdata' threshold(object, variable, lower, upper, sport, trace = FALSE, ...) threshold(object, ...)
## S3 method for class 'trackeRdata' threshold(object, variable, lower, upper, sport, trace = FALSE, ...) threshold(object, ...)
object |
An object of class |
variable |
A vector containing the names of the variables to which thresholding is applied. See Details. |
lower |
A vector containing the corresponding lower thresholds. See Details. |
upper |
A vector containing the corresponding upper thresholds. See Details. |
sport |
A vector of sports (amongst |
trace |
Should a progress report be printed? Default is |
... |
Currently not used. |
lower
and upper
are always understood as referring to
the units of the object
.
If the arguments variable
, lower
, and upper
are all unspecified, the following default thresholds are employed
latitude [-90, 90] degrees
longitude [-180, 180] degrees
altitude [-500, 9000] m
distance [0, Inf] meters
cadence_running [0, Inf] steps per min
cadence_cycling [0, Inf] revolutions per min
speed [0, Inf] meters
heart rate [0, 250] bpm
power [0, Inf] W
pace [0, Inf] min per km
duration [0, Inf] seconds
temperature [-20, 60] C
after they have been transformed to the units of the object
The thresholds for speed differ across sports: for running they are [0, 12.5] meters per second, for cycling [0, 100] meters per second and for swimming [0, 5] meters per second.
## Not run: data('runs', package = 'trackeR') plot(runs, session = 4, what = 'speed', threshold = FALSE) runsT <- threshold(runs, variable = 'speed', lower = 0, upper = 12.5, sport = "running") plot(runsT, session = 4, what = 'speed', threshold = FALSE) ## End(Not run)
## Not run: data('runs', package = 'trackeR') plot(runs, session = 4, what = 'speed', threshold = FALSE) runsT <- threshold(runs, variable = 'speed', lower = 0, upper = 12.5, sport = "running") plot(runsT, session = 4, what = 'speed', threshold = FALSE) ## End(Not run)
Time spent above a certain threshold.
timeAboveThreshold(object, threshold = -1, ge = TRUE)
timeAboveThreshold(object, threshold = -1, ge = TRUE)
object |
A (univariate) zoo object. |
threshold |
The threshold. |
ge |
Logical. Should time include the threshold (greater or equal to threshold) or not (greater only)? |
Generic function for visualising the sessions on a time versus date plot
Timeline plot for trackeRdata
objects.
Timeline plot for trackeRdataSummary
objects
timeline(object, lims, ...) ## S3 method for class 'trackeRdata' timeline(object, lims = NULL, ...) ## S3 method for class 'trackeRdataSummary' timeline(object, lims = NULL, ...)
timeline(object, lims, ...) ## S3 method for class 'trackeRdata' timeline(object, lims = NULL, ...) ## S3 method for class 'trackeRdataSummary' timeline(object, lims = NULL, ...)
object |
An object of class |
lims |
An optional vector of two times in HH:MM
format. Default is |
... |
Arguments passed to |
## Not run: data('runs', package = 'trackeR') ## timeline plot applied on the \code{trackeRdata} object directly and with ## inferred limits for the time axis timeline(runs) ## the same timeline plot applied on the \code{trackeRdataSummary} object runSummary <- summary(runs) timeline(runSummary, lims = c('00:01', '23:59')) ## End(Not run)
## Not run: data('runs', package = 'trackeR') ## timeline plot applied on the \code{trackeRdata} object directly and with ## inferred limits for the time axis timeline(runs) ## the same timeline plot applied on the \code{trackeRdataSummary} object runSummary <- summary(runs) timeline(runSummary, lims = c('00:01', '23:59')) ## End(Not run)
trackeR provides infrastructure for handling cycling and running data from GPS-enabled tracking devices. After extraction and appropriate manipulation of the training or competition attributes, the data are placed into session-aware data objects with an S3 class trackeRdata. The information in the resultant data objects can then be visualised, summarised and analysed through corresponding flexible and extensible methods.
Core facilities in the trackeR package, including reading functions
(see readX
), data pre-processing strategies (see
trackeRdata
), and calculation of concentration and
distribution profiles (see distributionProfile
and
concentrationProfile
) are based on un-packaged R code
that was developed by Ioannis Kosmidis for the requirements of the
analyses in Kosmidis & Passfield (2015).
This work has been supported by the English Institute of Sport (currently UK Sports Institute) https://uksportsinstitute.co.uk and University College London (UCL), which jointly contributed to the grant that funded Hannah Frick's Post Doctoral Research Fellowship at UCL between 2014 and 2016 and a percentage of Ioannis Kosmidis' time. Ioannis Kosmidis has also been supported by the Alan Turing Institute under the EPSRC grant EP/N510129/1 (Turing award number TU/B/000082). The support of the aforementioned organisations is greatly acknowledged.
Hannah Frick maintained trackeR from its first release up and since version 1.0.0.
Frick, H., Kosmidis, I. (2017). trackeR: Infrastructure for Running and Cycling Data from GPS-Enabled Tracking Devices in R. Journal of Statistical Software, 82(7), 1–29. doi:10.18637/jss.v082.i07
Kosmidis, I., and Passfield, L. (2015). Linking the Performance of Endurance Runners to Training and Physiological Effects via Multi-Resolution Elastic Net. ArXiv e-print arXiv:1506.01388.
Create a trackeRdata object from a data frame with observations being divided in separate training sessions. For breaks within a session observations are imputed.
trackeRdata( dat, units = NULL, sport = NULL, session_threshold = 2, correct_distances = FALSE, smooth_elevation_gain = TRUE, from_distances = TRUE, country = NULL, mask = TRUE, lgap = 30, lskip = 5, m = 11, silent = FALSE )
trackeRdata( dat, units = NULL, sport = NULL, session_threshold = 2, correct_distances = FALSE, smooth_elevation_gain = TRUE, from_distances = TRUE, country = NULL, mask = TRUE, lgap = 30, lskip = 5, m = 11, silent = FALSE )
dat |
A |
units |
The output of |
sport |
What sport does |
session_threshold |
The threshold in hours for the time difference between consecutive timestamps above which they are considered to belong to different training sessions. |
correct_distances |
Logical. Should the distances be corrected
for elevation? Default is |
smooth_elevation_gain |
Logical. Should the elevation gain be
smoothed before computing elevation gain? Default
is |
from_distances |
Logical. Should the speeds be calculated from the distance recordings instead of taken from the speed recordings directly? |
country |
ISO3 country code for downloading altitude data. If
|
mask |
Logical. Passed on to
|
lgap |
Time in seconds corresponding to the minimal sampling rate. |
lskip |
Time in seconds between the last observation before a small break and the first imputed speed or the last imputed speed and the first observation after a small break. |
m |
Number of imputed observations in each small break. |
silent |
Logical. Should warnings be generated if any of the sanity checks on the data are triggered? |
During small breaks within a session, e.g., because the recording device was paused, observations are imputed the following way: 0 for speed, last known position for latitude, longitude and altitude, NA or 0 power for running or cycling session, respectively, and NA for all other variables. Distances are (re-)calculated based on speeds after imputation.
trackeRdata
assumes that all observations in dat
are
from the same sport
, even if dat
ends up having
observations from different sessions (also depending on the value
of session_threshold
.
if attr(dat, 'sport')
is NA
then the current
implementation of trackeRdata
returns an error.
More details about the resulting trackeRdata
object are
available in the package vignette, which is an up-to-date version
of Frick & Kosmidis (2017).
Frick, H., Kosmidis, I. (2017). trackeR: Infrastructure for Running and Cycling Data from GPS-Enabled Tracking Devices in R. Journal of Statistical Software, 82(7), 1–29. doi:10.18637/jss.v082.i07
readContainer
for reading .tcx and .db3
files directly into trackeRdata
objects, and
get_elevation_gain
for details on the computation
of the elevation gain.
## read raw data filepath <- system.file('extdata/tcx/', '2013-06-08-090442.TCX.gz', package = 'trackeR') run0 <- readTCX(file = filepath, timezone = 'GMT') ## turn into trackeRdata object units0 <- generate_units() run0 <- trackeRdata(run0, units = units0)
## read raw data filepath <- system.file('extdata/tcx/', '2013-06-08-090442.TCX.gz', package = 'trackeR') run0 <- readTCX(file = filepath, timezone = 'GMT') ## turn into trackeRdata object units0 <- generate_units() run0 <- trackeRdata(run0, units = units0)
trackerRdata
objectExtract unique sessions in a trackerRdata
object
## S3 method for class 'trackeRdata' unique(x, incomparables = FALSE, ...)
## S3 method for class 'trackeRdata' unique(x, incomparables = FALSE, ...)
x |
A |
incomparables |
Currently not used. |
... |
Currently not used. |
Uniqueness is determined by comparing the first timestamp of the
sessions in the trackeRdata
object.
Calculate W' expended, i.e., the work capacity above critical power/speed which has been depleted and not yet been replenished.
Wexp(object, w0, cp, version = c("2015", "2012"), meanRecoveryPower = FALSE)
Wexp(object, w0, cp, version = c("2015", "2012"), meanRecoveryPower = FALSE)
object |
Univariate |
w0 |
Initial capacity of W', as calculated based on the critical power model by Monod and Scherrer (1965). |
cp |
Critical power/speed, i.e., the power/speed which can be maintained for longer period of time. |
version |
How should W' be replenished? Options include
|
meanRecoveryPower |
Should the mean of all power outputs below critical power be used as recovery power? See Details. |
Skiba et al. (2015) and Skiba et al. (2012) both describe an
exponential decay of expended over an interval
if the power output during this interval is
below critical power:
However, the factor nu differs: Skiba et al. (2012) describe it as
with
estimated as
Skiba et al. (2015) use . Skiba et
al. (2012) and Skiba et al. (2015) employ a constant recovery power
(calculated as the mean over all power outputs below critical
power). This rationale can be applied by setting the argument
meanRecoveryPower
to TRUE
. Note that this uses
information from all observations with a power output below
critical power, not just those prior to the current time point.
Monod H, Scherrer J (1965). 'The Work Capacity of a Synergic Muscular Group.' Ergonomics, 8(3), 329–338.
Skiba PF, Chidnok W, Vanhatalo A, Jones AM (2012). 'Modeling the Expenditure and Reconstitution of Work Capacity above Critical Power.' Medicine & Science in Sports & Exercise, 44(8), 1526–1532.
Skiba PF, Fulford J, Clarke DC, Vanhatalo A, Jones AM (2015). 'Intramuscular Determinants of the Ability to Recover Work Capacity above Critical Power.' European Journal of Applied Physiology, 115(4), 703–713.
W': work capacity above critical power/speed.
Wprime( object, session = NULL, quantity = c("expended", "balance"), w0, cp, version = c("2015", "2012"), meanRecoveryPower = FALSE, parallel = FALSE, ... )
Wprime( object, session = NULL, quantity = c("expended", "balance"), w0, cp, version = c("2015", "2012"), meanRecoveryPower = FALSE, parallel = FALSE, ... )
object |
A |
session |
A numeric vector of the sessions to be used, defaults to all sessions. |
quantity |
Should W' |
w0 |
Initial capacity of W', as calculated based on the critical power model by Monod and Scherrer (1965). |
cp |
Critical power/speed, i.e., the power/speed which can be maintained for longer period of time. |
version |
How should W' be replenished? Options include
|
meanRecoveryPower |
Should the mean of all power outputs below critical power be used as recovery power? See Details. |
parallel |
Logical. Should computation be carried out in
parallel? If |
... |
Currently not used. |
#' Skiba et al. (2015) and Skiba et al. (2012) both describe an
exponential decay of expended over an interval
if the power output during this interval is
below critical power:
However, the factor nu differs: Skiba et al. (2012) describe it as
with
estimated as
Skiba et al. (2015) use . Skiba et
al. (2012) and Skiba et al. (2015) employ a constant recovery power
(calculated as the mean over all power outputs below critical
power). This rationale can be applied by setting the argument
meanRecoveryPower
to TRUE
. Note that this uses
information from all observations with a power output below
critical power, not just those prior to the current time point.
An object of class trackeRWprime
.
Monod H, Scherrer J (1965). 'The Work Capacity of a Synergic Muscular Group.' Ergonomics, 8(3), 329–338.
Skiba PF, Chidnok W, Vanhatalo A, Jones AM (2012). 'Modeling the Expenditure and Reconstitution of Work Capacity above Critical Power.' Medicine & Science in Sports & Exercise, 44(8), 1526–1532.
Skiba PF, Fulford J, Clarke DC, Vanhatalo A, Jones AM (2015). 'Intramuscular Determinants of the Ability to Recover Work Capacity above Critical Power.' European Journal of Applied Physiology, 115(4), 703–713.
## Not run: data('runs', package = 'trackeR') wexp <- Wprime(runs, session = c(11,13), cp = 4, version = '2012') plot(wexp) ## End(Not run)
## Not run: data('runs', package = 'trackeR') wexp <- Wprime(runs, session = c(11,13), cp = 4, version = '2012') plot(wexp) ## End(Not run)
Time spent in training zones.
zones( object, session = NULL, what = c("speed"), breaks = NULL, parallel = FALSE, n_zones = 9, unit_reference_sport = NULL, ... )
zones( object, session = NULL, what = c("speed"), breaks = NULL, parallel = FALSE, n_zones = 9, unit_reference_sport = NULL, ... )
object |
An object of class |
session |
A numeric vector of the sessions to be plotted, defaults to all sessions. |
what |
A vector of variable names. |
breaks |
A list of breakpoints between zones, corresponding to
the variables in |
parallel |
Logical. Should computation be carried out in
parallel? If |
n_zones |
numeric that sets the number of zones for data to be
split into. Default is |
unit_reference_sport |
The sport to inherit units from
(default is taken to be the most frequent sport in
|
... |
Currently not used. |
An object of class trackeRdataZones
.
data('run', package = 'trackeR') runZones <- zones(run, what = 'speed', breaks = list(speed = c(0, 2:6, 12.5))) ## if breaks is a named list, argument 'what' can be left unspecified runZones <- zones(run, breaks = list(speed = c(0, 2:6, 12.5))) ## if only a single variable is to be evaluated, 'breaks' can also be a vector runZones <- zones(run, what = 'speed', breaks = c(0, 2:6, 12.5)) plot(runZones)
data('run', package = 'trackeR') runZones <- zones(run, what = 'speed', breaks = list(speed = c(0, 2:6, 12.5))) ## if breaks is a named list, argument 'what' can be left unspecified runZones <- zones(run, breaks = list(speed = c(0, 2:6, 12.5))) ## if only a single variable is to be evaluated, 'breaks' can also be a vector runZones <- zones(run, what = 'speed', breaks = c(0, 2:6, 12.5)) plot(runZones)