├── .github ├── .gitignore └── workflows │ └── R-CMD-check.yaml ├── data ├── run.rda └── runs.rda ├── inst ├── icons │ ├── start.png │ └── finish.png ├── extdata │ ├── tcx │ │ ├── 2013-06-01-183220.TCX.gz │ │ ├── 2013-06-02-072348.TCX.gz │ │ ├── 2013-06-03-184846.TCX.gz │ │ ├── 2013-06-04-174137.TCX.gz │ │ ├── 2013-06-05-062419.TCX.gz │ │ ├── 2013-06-06-124422.TCX.gz │ │ ├── 2013-06-08-090442.TCX.gz │ │ ├── 2013-06-09-165756.TCX.gz │ │ ├── 2013-06-11-181035.TCX.gz │ │ ├── 2013-06-12-182257.TCX.gz │ │ ├── 2013-06-14-095723.TCX.gz │ │ ├── 2013-06-14-100911.TCX.gz │ │ ├── 2013-06-14-105252.TCX.gz │ │ ├── 2013-06-15-084005.TCX.gz │ │ ├── 2013-06-15-090638.TCX.gz │ │ ├── 2013-06-16-124414.TCX.gz │ │ ├── 2013-06-17-182443.TCX.gz │ │ ├── 2013-06-18-063609.TCX.gz │ │ ├── 2013-06-19-174449.TCX.gz │ │ ├── 2013-06-19-175630.TCX.gz │ │ ├── 2013-06-19-183041.TCX.gz │ │ ├── 2013-06-20-180628.TCX.gz │ │ ├── 2013-06-21-174510.TCX.gz │ │ ├── 2013-06-22-150811.TCX.gz │ │ ├── 2013-06-23-080959.TCX.gz │ │ ├── 2013-06-23-100845.TCX.gz │ │ ├── 2013-06-24-151957.TCX.gz │ │ ├── 2013-06-25-174514.TCX.gz │ │ ├── 2013-06-26-181438.TCX.gz │ │ ├── 2013-06-28-062238.TCX.gz │ │ ├── 2013-06-29-064742.TCX.gz │ │ ├── 2013-06-30-070511.TCX.gz │ │ └── 2013-06-30-084200.TCX.gz │ ├── gpx │ │ ├── 20170708-154835-Run.gpx.gz │ │ ├── 20170709-151453-Ride.gpx.gz │ │ └── 20170714-143644-Swim.gpx.gz │ └── json │ │ └── 2017_04_24_10_18_45.json.gz ├── CITATION └── WORDLIST ├── tests ├── testthat.R ├── spelling.R └── testthat │ ├── test-zones.R │ ├── test-extraction.R │ ├── test-cleaning.R │ ├── test-generate.R │ ├── test-summary.R │ ├── test-threshold.R │ ├── test-trackeRdata.R │ ├── test-distribution-profiles.R │ ├── test-reading.R │ ├── test-units.R │ └── test-concentration_profile.R ├── vignettes └── plotRouteGoogle.pdf ├── README_files └── figure-markdown_strict │ ├── plots-1.png │ ├── cprofile-1.png │ ├── funPCA-1.png │ ├── scores-1.png │ ├── scores-2.png │ ├── summary-1.png │ ├── plots_new-1.png │ ├── cprofile-ridges-1.png │ └── cprofile-ridges-hr-1.png ├── R ├── data.R ├── parallelization.R ├── zzz_aliases.R ├── trackeRdata_smoother.R └── thresholds.R ├── man ├── run.Rd ├── runs.Rd ├── scaled.Rd ├── c2d.Rd ├── smoother.Rd ├── find_unit_reference_sport.Rd ├── get_units.conProfile.Rd ├── append.Rd ├── ridges.Rd ├── get_units.trackeRfpca.Rd ├── get_units.distrProfile.Rd ├── distance2speed.Rd ├── get_units.trackeRdata.Rd ├── get_units.trackeRWprime.Rd ├── append.trackeRdata.Rd ├── get_operations.trackeRdata.Rd ├── get_units.Rd ├── get_units.trackeRthresholds.Rd ├── get_units.trackeRdataZones.Rd ├── get_units.trackeRdataSummary.Rd ├── timeAboveThreshold.Rd ├── get_operations.Rd ├── get_operations.conProfile.Rd ├── sanity_checks.Rd ├── get_operations.distrProfile.Rd ├── print.trackeRdataSummary.Rd ├── speed2distance.Rd ├── sort.trackeRdata.Rd ├── collect_units.Rd ├── unique.trackeRdata.Rd ├── change_units.trackeRWprime.Rd ├── change_units.distrProfile.Rd ├── change_units.conProfile.Rd ├── fortify.trackeRdata.Rd ├── prettifyUnit.Rd ├── fortify.distrProfile.Rd ├── fortify.conProfile.Rd ├── plot.trackeRdataZones.Rd ├── fortify.trackeRWprime.Rd ├── fortify.trackeRdataSummary.Rd ├── compute_limits.Rd ├── change_units.trackeRdataZones.Rd ├── change_units.trackeRdataSummary.Rd ├── scaled.distrProfile.Rd ├── get_resting_periods.Rd ├── change_units.trackeRdata.Rd ├── nsessions.Rd ├── session_times.Rd ├── change_units.Rd ├── print.trackeRdata.Rd ├── change_units.trackeRthresholds.Rd ├── plot.trackeRWprime.Rd ├── ridges.trackeRdata.Rd ├── generate_thresholds.Rd ├── smoother_control.distrProfile.Rd ├── session_duration.Rd ├── decreasing_smoother.Rd ├── leaflet_route.Rd ├── get_profile.Rd ├── ridges.distrProfile.Rd ├── get_sport.Rd ├── ridges.conProfile.Rd ├── get_elevation_gain.Rd ├── smoother.trackeRdata.Rd ├── plot.conProfile.Rd ├── plot.distrProfile.Rd ├── prepare_route.Rd ├── smoother.conProfile.Rd ├── compute_breaks.Rd ├── profile2fd.Rd ├── timeline.Rd ├── plot.trackeRfpca.Rd ├── plot.trackeRdataSummary.Rd ├── funPCA.Rd ├── concentration_profile.Rd ├── smoother_control.trackeRdata.Rd ├── GC2trackeRdata.Rd ├── zones.Rd ├── smoother.distrProfile.Rd ├── generate_units.Rd ├── impute_speeds.Rd ├── plot_route.Rd ├── threshold.trackeRdata.Rd ├── summary.trackeRdata.Rd ├── Wexp.Rd ├── readX.Rd ├── trackeR.Rd ├── plot.trackeRdata.Rd ├── distribution_profile.Rd ├── concentration_profile.distrProfile.Rd ├── trackeRdata.Rd ├── Wprime.Rd ├── read_container.Rd ├── read_directory.Rd └── conversions.Rd ├── data-raw ├── sticker.R └── run.R ├── .Rbuildignore ├── DESCRIPTION ├── .gitignore ├── README.Rmd └── README.md /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /data/run.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/data/run.rda -------------------------------------------------------------------------------- /data/runs.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/data/runs.rda -------------------------------------------------------------------------------- /inst/icons/start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/icons/start.png -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library("testthat") 2 | library("trackeR") 3 | 4 | test_check("trackeR") 5 | -------------------------------------------------------------------------------- /inst/icons/finish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/icons/finish.png -------------------------------------------------------------------------------- /vignettes/plotRouteGoogle.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/vignettes/plotRouteGoogle.pdf -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-01-183220.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-01-183220.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-02-072348.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-02-072348.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-03-184846.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-03-184846.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-04-174137.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-04-174137.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-05-062419.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-05-062419.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-06-124422.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-06-124422.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-08-090442.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-08-090442.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-09-165756.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-09-165756.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-11-181035.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-11-181035.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-12-182257.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-12-182257.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-14-095723.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-14-095723.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-14-100911.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-14-100911.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-14-105252.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-14-105252.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-15-084005.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-15-084005.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-15-090638.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-15-090638.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-16-124414.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-16-124414.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-17-182443.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-17-182443.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-18-063609.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-18-063609.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-19-174449.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-19-174449.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-19-175630.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-19-175630.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-19-183041.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-19-183041.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-20-180628.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-20-180628.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-21-174510.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-21-174510.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-22-150811.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-22-150811.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-23-080959.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-23-080959.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-23-100845.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-23-100845.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-24-151957.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-24-151957.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-25-174514.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-25-174514.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-26-181438.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-26-181438.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-28-062238.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-28-062238.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-29-064742.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-29-064742.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-30-070511.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-30-070511.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/tcx/2013-06-30-084200.TCX.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/tcx/2013-06-30-084200.TCX.gz -------------------------------------------------------------------------------- /inst/extdata/gpx/20170708-154835-Run.gpx.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/gpx/20170708-154835-Run.gpx.gz -------------------------------------------------------------------------------- /inst/extdata/gpx/20170709-151453-Ride.gpx.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/gpx/20170709-151453-Ride.gpx.gz -------------------------------------------------------------------------------- /inst/extdata/gpx/20170714-143644-Swim.gpx.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/gpx/20170714-143644-Swim.gpx.gz -------------------------------------------------------------------------------- /inst/extdata/json/2017_04_24_10_18_45.json.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/inst/extdata/json/2017_04_24_10_18_45.json.gz -------------------------------------------------------------------------------- /README_files/figure-markdown_strict/plots-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/README_files/figure-markdown_strict/plots-1.png -------------------------------------------------------------------------------- /README_files/figure-markdown_strict/cprofile-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/README_files/figure-markdown_strict/cprofile-1.png -------------------------------------------------------------------------------- /README_files/figure-markdown_strict/funPCA-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/README_files/figure-markdown_strict/funPCA-1.png -------------------------------------------------------------------------------- /README_files/figure-markdown_strict/scores-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/README_files/figure-markdown_strict/scores-1.png -------------------------------------------------------------------------------- /README_files/figure-markdown_strict/scores-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/README_files/figure-markdown_strict/scores-2.png -------------------------------------------------------------------------------- /README_files/figure-markdown_strict/summary-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/README_files/figure-markdown_strict/summary-1.png -------------------------------------------------------------------------------- /README_files/figure-markdown_strict/plots_new-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/README_files/figure-markdown_strict/plots_new-1.png -------------------------------------------------------------------------------- /README_files/figure-markdown_strict/cprofile-ridges-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/README_files/figure-markdown_strict/cprofile-ridges-1.png -------------------------------------------------------------------------------- /README_files/figure-markdown_strict/cprofile-ridges-hr-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trackerproject/trackeR/HEAD/README_files/figure-markdown_strict/cprofile-ridges-hr-1.png -------------------------------------------------------------------------------- /tests/spelling.R: -------------------------------------------------------------------------------- 1 | if(requireNamespace('spelling', quietly = TRUE)) 2 | spelling::spell_check_test(vignettes = TRUE, error = FALSE, 3 | skip_on_cran = TRUE) 4 | -------------------------------------------------------------------------------- /R/data.R: -------------------------------------------------------------------------------- 1 | #' Training session. 2 | #' 3 | #' @format A \code{\link{trackeRdata}} object containing one running training session. 4 | "run" 5 | 6 | #' Training sessions. 7 | #' 8 | #' @format A \code{\link{trackeRdata}} object containing 33 running training sessions. 9 | "runs" 10 | 11 | -------------------------------------------------------------------------------- /man/run.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{run} 5 | \alias{run} 6 | \title{Training session.} 7 | \format{ 8 | A \code{\link{trackeRdata}} object containing one running training session. 9 | } 10 | \usage{ 11 | run 12 | } 13 | \description{ 14 | Training session. 15 | } 16 | \keyword{datasets} 17 | -------------------------------------------------------------------------------- /man/runs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{runs} 5 | \alias{runs} 6 | \title{Training sessions.} 7 | \format{ 8 | A \code{\link{trackeRdata}} object containing 33 running training sessions. 9 | } 10 | \usage{ 11 | runs 12 | } 13 | \description{ 14 | Training sessions. 15 | } 16 | \keyword{datasets} 17 | -------------------------------------------------------------------------------- /man/scaled.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeR.R 3 | \name{scaled} 4 | \alias{scaled} 5 | \title{Generic function for scaling} 6 | \usage{ 7 | scaled(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{The object to be scaled.} 11 | 12 | \item{...}{Arguments to be passed to methods.} 13 | } 14 | \description{ 15 | Generic function for scaling 16 | } 17 | -------------------------------------------------------------------------------- /man/c2d.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/concentrationProfile.R 3 | \name{c2d} 4 | \alias{c2d} 5 | \title{Transform concentration profile to distribution profile.} 6 | \usage{ 7 | c2d(cp) 8 | } 9 | \arguments{ 10 | \item{cp}{Single concentration profile as a zoo object.} 11 | } 12 | \description{ 13 | Transform concentration profile to distribution profile. 14 | } 15 | -------------------------------------------------------------------------------- /man/smoother.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeR.R 3 | \name{smoother} 4 | \alias{smoother} 5 | \title{Generic function for smoothing} 6 | \usage{ 7 | smoother(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{The object to be smoothed.} 11 | 12 | \item{...}{Arguments to be passed to methods.} 13 | } 14 | \description{ 15 | Generic function for smoothing 16 | } 17 | -------------------------------------------------------------------------------- /R/parallelization.R: -------------------------------------------------------------------------------- 1 | ## Code adapted from plyr 1.8.4.9000 2 | 3 | setup_parallel <- function() { 4 | if (!requireNamespace("foreach", quietly = TRUE)) { 5 | # EXCLUDE COVERAGE START 6 | stop("foreach package required for parallel operation", 7 | call. = FALSE) 8 | # EXCLUDE COVERAGE END 9 | } 10 | if (foreach::getDoParWorkers() == 1) { 11 | # EXCLUDE COVERAGE START 12 | warning("No parallel backend registered", call. = TRUE) 13 | # EXCLUDE COVERAGE END 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /man/find_unit_reference_sport.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{find_unit_reference_sport} 4 | \alias{find_unit_reference_sport} 5 | \title{Find the most frequent sport in an \code{object}} 6 | \usage{ 7 | find_unit_reference_sport(object) 8 | } 9 | \arguments{ 10 | \item{object}{any object with a \code{\link{get_sport}} method 11 | implemented (run \code{methods(get_sport)}).} 12 | } 13 | \description{ 14 | Find the most frequent sport in an \code{object} 15 | } 16 | -------------------------------------------------------------------------------- /man/get_units.conProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/units.R 3 | \name{get_units.conProfile} 4 | \alias{get_units.conProfile} 5 | \title{Get the units of the variables in an \code{conProfile} object} 6 | \usage{ 7 | \method{get_units}{conProfile}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{conProfile}.} 11 | 12 | \item{...}{Currently not used.} 13 | } 14 | \description{ 15 | Get the units of the variables in an \code{conProfile} object 16 | } 17 | -------------------------------------------------------------------------------- /man/append.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeR.R 3 | \name{append} 4 | \alias{append} 5 | \title{Generic function for appending data to existing files} 6 | \usage{ 7 | append(object, file, ...) 8 | } 9 | \arguments{ 10 | \item{object}{The object to be appended.} 11 | 12 | \item{file}{The file to which \code{object} is to be appended.} 13 | 14 | \item{...}{Arguments to be passed to methods.} 15 | } 16 | \description{ 17 | Generic function for appending data to existing files 18 | } 19 | -------------------------------------------------------------------------------- /man/ridges.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeR.R 3 | \name{ridges} 4 | \alias{ridges} 5 | \title{Generic function for ridgeline plots} 6 | \usage{ 7 | ridges(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{distrProfile} or 11 | \code{conProfile}.} 12 | 13 | \item{...}{Arguments to be passed to methods.} 14 | } 15 | \description{ 16 | Generic function for ridgeline plots 17 | } 18 | \seealso{ 19 | ridges.trackeRdata ridges.conProfile ridges.distrProfile 20 | } 21 | -------------------------------------------------------------------------------- /man/get_units.trackeRfpca.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/units.R 3 | \name{get_units.trackeRfpca} 4 | \alias{get_units.trackeRfpca} 5 | \title{Get the units of the variables in an \code{trackeRfpca} object} 6 | \usage{ 7 | \method{get_units}{trackeRfpca}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{trackeRfpca}.} 11 | 12 | \item{...}{Currently not used.} 13 | } 14 | \description{ 15 | Get the units of the variables in an \code{trackeRfpca} object 16 | } 17 | -------------------------------------------------------------------------------- /man/get_units.distrProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/units.R 3 | \name{get_units.distrProfile} 4 | \alias{get_units.distrProfile} 5 | \title{Get the units of the variables in an \code{distrProfile} object} 6 | \usage{ 7 | \method{get_units}{distrProfile}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{distrProfile}.} 11 | 12 | \item{...}{Currently not used.} 13 | } 14 | \description{ 15 | Get the units of the variables in an \code{distrProfile} object 16 | } 17 | -------------------------------------------------------------------------------- /man/distance2speed.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cleaning.R 3 | \name{distance2speed} 4 | \alias{distance2speed} 5 | \title{Convert distance to speed.} 6 | \usage{ 7 | distance2speed(distance, time, timeunit) 8 | } 9 | \arguments{ 10 | \item{distance}{Distance in meters.} 11 | 12 | \item{time}{Time.} 13 | 14 | \item{timeunit}{Time unit in speed, e.g., "hours" for speed in *_per_h.} 15 | } 16 | \value{ 17 | Speed in meters per second. 18 | } 19 | \description{ 20 | Convert distance to speed. 21 | } 22 | -------------------------------------------------------------------------------- /man/get_units.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata.R 3 | \name{get_units.trackeRdata} 4 | \alias{get_units.trackeRdata} 5 | \title{Get the units of the variables in an \code{trackeRdata} object} 6 | \usage{ 7 | \method{get_units}{trackeRdata}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{\link{trackeRdata}}.} 11 | 12 | \item{...}{Currently not used.} 13 | } 14 | \description{ 15 | Get the units of the variables in an \code{trackeRdata} object 16 | } 17 | -------------------------------------------------------------------------------- /man/get_units.trackeRWprime.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/units.R 3 | \name{get_units.trackeRWprime} 4 | \alias{get_units.trackeRWprime} 5 | \title{Get the units of the variables in an \code{trackeRWprime} object} 6 | \usage{ 7 | \method{get_units}{trackeRWprime}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{trackeRWprime}.} 11 | 12 | \item{...}{Currently not used.} 13 | } 14 | \description{ 15 | Get the units of the variables in an \code{trackeRWprime} object 16 | } 17 | -------------------------------------------------------------------------------- /man/append.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata.R 3 | \name{append.trackeRdata} 4 | \alias{append.trackeRdata} 5 | \title{Append training sessions to existing file} 6 | \usage{ 7 | \method{append}{trackeRdata}(object, file, ...) 8 | } 9 | \arguments{ 10 | \item{object}{The object to be appended.} 11 | 12 | \item{file}{The file to which \code{object} is to be appended.} 13 | 14 | \item{...}{Currently not used.} 15 | } 16 | \description{ 17 | Append training sessions to existing file 18 | } 19 | -------------------------------------------------------------------------------- /man/get_operations.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata.R 3 | \name{get_operations.trackeRdata} 4 | \alias{get_operations.trackeRdata} 5 | \title{Get the operation settings of an \code{trackeRdata} object} 6 | \usage{ 7 | \method{get_operations}{trackeRdata}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{\link{trackeRdata}}.} 11 | 12 | \item{...}{Currently not used.} 13 | } 14 | \description{ 15 | Get the operation settings of an \code{trackeRdata} object 16 | } 17 | -------------------------------------------------------------------------------- /man/get_units.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeR.R, R/zzz_aliases.R 3 | \name{get_units} 4 | \alias{get_units} 5 | \alias{getUnits} 6 | \title{Generic function for extracting the units of measurement} 7 | \usage{ 8 | get_units(object, ...) 9 | 10 | getUnits(object, ...) 11 | } 12 | \arguments{ 13 | \item{object}{The object of which the units of measurement are retrieved.} 14 | 15 | \item{...}{Arguments to be passed to methods.} 16 | } 17 | \description{ 18 | Generic function for extracting the units of measurement 19 | } 20 | -------------------------------------------------------------------------------- /man/get_units.trackeRthresholds.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/units.R 3 | \name{get_units.trackeRthresholds} 4 | \alias{get_units.trackeRthresholds} 5 | \title{Get the units of the variables in an \code{trackeRthresholds} object} 6 | \usage{ 7 | \method{get_units}{trackeRthresholds}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{trackeRthresholds}.} 11 | 12 | \item{...}{Currently not used.} 13 | } 14 | \description{ 15 | Get the units of the variables in an \code{trackeRthresholds} object 16 | } 17 | -------------------------------------------------------------------------------- /man/get_units.trackeRdataZones.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_zones.R 3 | \name{get_units.trackeRdataZones} 4 | \alias{get_units.trackeRdataZones} 5 | \title{Get the units of the variables in an \code{trackeRdataZones} object} 6 | \usage{ 7 | \method{get_units}{trackeRdataZones}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{trackeRdataZones}.} 11 | 12 | \item{...}{Currently not used.} 13 | } 14 | \description{ 15 | Get the units of the variables in an \code{trackeRdataZones} object 16 | } 17 | -------------------------------------------------------------------------------- /man/get_units.trackeRdataSummary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_summary.R 3 | \name{get_units.trackeRdataSummary} 4 | \alias{get_units.trackeRdataSummary} 5 | \title{Get the units of the variables in an \code{trackeRdataSummary} object} 6 | \usage{ 7 | \method{get_units}{trackeRdataSummary}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{trackeRdataSummary}.} 11 | 12 | \item{...}{Currently not used.} 13 | } 14 | \description{ 15 | Get the units of the variables in an \code{trackeRdataSummary} object 16 | } 17 | -------------------------------------------------------------------------------- /man/timeAboveThreshold.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{timeAboveThreshold} 4 | \alias{timeAboveThreshold} 5 | \title{Time spent above a certain threshold.} 6 | \usage{ 7 | timeAboveThreshold(object, threshold = -1, ge = TRUE) 8 | } 9 | \arguments{ 10 | \item{object}{A (univariate) zoo object.} 11 | 12 | \item{threshold}{The threshold.} 13 | 14 | \item{ge}{Logical. Should time include the threshold (greater or equal to threshold) or not (greater only)?} 15 | } 16 | \description{ 17 | Time spent above a certain threshold. 18 | } 19 | -------------------------------------------------------------------------------- /man/get_operations.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeR.R, R/zzz_aliases.R 3 | \name{get_operations} 4 | \alias{get_operations} 5 | \alias{getOperations} 6 | \title{Generic function for retrieving the operation settings} 7 | \usage{ 8 | get_operations(object, ...) 9 | 10 | getOperations(object, ...) 11 | } 12 | \arguments{ 13 | \item{object}{The object of which the units of measurement are retrieved.} 14 | 15 | \item{...}{Arguments to be passed to methods.} 16 | } 17 | \description{ 18 | Generic function for retrieving the operation settings 19 | } 20 | -------------------------------------------------------------------------------- /man/get_operations.conProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/concentrationProfile.R 3 | \name{get_operations.conProfile} 4 | \alias{get_operations.conProfile} 5 | \title{Get the operation settings of an \code{conProfile} object} 6 | \usage{ 7 | \method{get_operations}{conProfile}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{conProfile} as returned by \code{\link{concentrationProfile}}.} 11 | 12 | \item{...}{Currently not used.} 13 | } 14 | \description{ 15 | Get the operation settings of an \code{conProfile} object 16 | } 17 | -------------------------------------------------------------------------------- /man/sanity_checks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cleaning.R 3 | \name{sanity_checks} 4 | \alias{sanity_checks} 5 | \title{Sanity checks for tracking data} 6 | \usage{ 7 | sanity_checks(dat, silent) 8 | } 9 | \arguments{ 10 | \item{dat}{Data set to be cleaned up.} 11 | 12 | \item{silent}{Logical. Should warnings be generated if any of the 13 | sanity checks on the data are triggered?} 14 | } 15 | \description{ 16 | Heart rate measurements of 0 are set to NA, assuming the athlete is alive. 17 | Observations with missing or duplicated time stamps are removed. 18 | } 19 | -------------------------------------------------------------------------------- /man/get_operations.distrProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R 3 | \name{get_operations.distrProfile} 4 | \alias{get_operations.distrProfile} 5 | \title{Get the operation settings of an \code{distrProfile} object} 6 | \usage{ 7 | \method{get_operations}{distrProfile}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{distrProfile} as returned by \code{\link{distributionProfile}}.} 11 | 12 | \item{...}{Currently not used.} 13 | } 14 | \description{ 15 | Get the operation settings of an \code{distrProfile} object 16 | } 17 | -------------------------------------------------------------------------------- /man/print.trackeRdataSummary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_summary.R 3 | \name{print.trackeRdataSummary} 4 | \alias{print.trackeRdataSummary} 5 | \title{Print method for session summaries.} 6 | \usage{ 7 | \method{print}{trackeRdataSummary}(x, ..., digits = 2) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{trackeRdataSummary}.} 11 | 12 | \item{...}{Not used, for compatibility with generic summary method only.} 13 | 14 | \item{digits}{Number of digits to be printed.} 15 | } 16 | \description{ 17 | Print method for session summaries. 18 | } 19 | -------------------------------------------------------------------------------- /man/speed2distance.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cleaning.R 3 | \name{speed2distance} 4 | \alias{speed2distance} 5 | \title{Convert speed to distance.} 6 | \usage{ 7 | speed2distance(speed, time, timeunit, cumulative = TRUE) 8 | } 9 | \arguments{ 10 | \item{speed}{Speed in meters per second.} 11 | 12 | \item{time}{Time.} 13 | 14 | \item{timeunit}{Time unit in speed, e.g., "hours" for speed in *_per_h.} 15 | 16 | \item{cumulative}{Logical. Should the cumulative distances be returned?} 17 | } 18 | \value{ 19 | Distance in meters. 20 | } 21 | \description{ 22 | Convert speed to distance. 23 | } 24 | -------------------------------------------------------------------------------- /man/sort.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata.R 3 | \name{sort.trackeRdata} 4 | \alias{sort.trackeRdata} 5 | \title{Sort sessions in \code{\link{trackeRdata}} objects} 6 | \usage{ 7 | \method{sort}{trackeRdata}(x, decreasing = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A \code{trackeRdata} object.} 11 | 12 | \item{decreasing}{Logical. Should the objects be sorted in 13 | increasing or decreasing order?} 14 | 15 | \item{...}{Currently not used.} 16 | } 17 | \description{ 18 | Sort the sessions \code{\link{trackeRdata}} objects into ascending 19 | or descending order according to the first session timestamp. 20 | } 21 | -------------------------------------------------------------------------------- /man/collect_units.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{collect_units} 4 | \alias{collect_units} 5 | \title{Collect units from the result of \code{\link{generate_units}}} 6 | \usage{ 7 | collect_units(object, unit_reference_sport = NULL) 8 | } 9 | \arguments{ 10 | \item{object}{a \code{data.frame}, as returned by 11 | \code{\link{generate_units}}} 12 | 13 | \item{unit_reference_sport}{The sport to inherit units from 14 | (default is taken to be the most frequent sport in 15 | \code{object}).} 16 | } 17 | \description{ 18 | Collects the units from the results of \code{\link{generate_units}} 19 | according to a \code{unit_reference_sport} 20 | } 21 | -------------------------------------------------------------------------------- /man/unique.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata.R 3 | \name{unique.trackeRdata} 4 | \alias{unique.trackeRdata} 5 | \title{Extract unique sessions in a \code{trackerRdata} object} 6 | \usage{ 7 | \method{unique}{trackeRdata}(x, incomparables = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A \code{trackeRdata} object.} 11 | 12 | \item{incomparables}{Currently not used.} 13 | 14 | \item{...}{Currently not used.} 15 | } 16 | \description{ 17 | Extract unique sessions in a \code{trackerRdata} object 18 | } 19 | \details{ 20 | Uniqueness is determined by comparing the first timestamp of the 21 | sessions in the \code{trackeRdata} object. 22 | } 23 | -------------------------------------------------------------------------------- /man/change_units.trackeRWprime.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Wprime.R 3 | \name{change_units.trackeRWprime} 4 | \alias{change_units.trackeRWprime} 5 | \title{Change the units of the variables in an \code{\link{trackeRWprime}} object} 6 | \usage{ 7 | \method{change_units}{trackeRWprime}(object, variable, unit, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{\link{trackeRWprime}}.} 11 | 12 | \item{variable}{A vector of variables to be changed.} 13 | 14 | \item{unit}{A vector with the units, corresponding to variable.} 15 | 16 | \item{...}{Currently not used.} 17 | } 18 | \description{ 19 | Change the units of the variables in an \code{\link{trackeRWprime}} object 20 | } 21 | -------------------------------------------------------------------------------- /man/change_units.distrProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R 3 | \name{change_units.distrProfile} 4 | \alias{change_units.distrProfile} 5 | \title{Change the units of the variables in an \code{distrProfile} object} 6 | \usage{ 7 | \method{change_units}{distrProfile}(object, variable, unit, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{distrProfile} as returned by \code{\link{distributionProfile}}.} 11 | 12 | \item{variable}{A vector of variables to be changed.} 13 | 14 | \item{unit}{A vector with the units, corresponding to variable.} 15 | 16 | \item{...}{Currently not used.} 17 | } 18 | \description{ 19 | Change the units of the variables in an \code{distrProfile} object 20 | } 21 | -------------------------------------------------------------------------------- /man/change_units.conProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R 3 | \name{change_units.conProfile} 4 | \alias{change_units.conProfile} 5 | \title{Change the units of the variables in an \code{\link{conProfile}} object} 6 | \usage{ 7 | \method{change_units}{conProfile}(object, variable, unit, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{\link{conProfile}} as returned by \code{\link{concentrationProfile}}.} 11 | 12 | \item{variable}{A vector of variables to be changed.} 13 | 14 | \item{unit}{A vector with the units, corresponding to variable.} 15 | 16 | \item{...}{Currently not used.} 17 | } 18 | \description{ 19 | Change the units of the variables in an \code{\link{conProfile}} object 20 | } 21 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | bibentry(bibtype = "Article", 2 | title = "{trackeR}: Infrastructure for Running and Cycling Data from GPS-Enabled Tracking Devices in {R}", 3 | author = c(person(given = "Hannah", 4 | family = "Frick", 5 | email = "h.frick@ucl.ac.uk"), 6 | person(given = "Ioannis", 7 | family = "Kosmidis", 8 | email = "i.kosmidis@ucl.ac.uk")), 9 | journal = "Journal of Statistical Software", 10 | year = "2017", 11 | volume = "82", 12 | number = "7", 13 | pages = "1--29", 14 | doi = "10.18637/jss.v082.i07", 15 | 16 | header = "To cite trackeR in publications use:" 17 | ) 18 | 19 | -------------------------------------------------------------------------------- /man/fortify.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_plot.R, R/zzz_aliases.R 3 | \name{fortify.trackeRdata} 4 | \alias{fortify.trackeRdata} 5 | \alias{fortify_trackeRdata} 6 | \title{Fortify a trackeRdata object for plotting with ggplot2} 7 | \usage{ 8 | \method{fortify}{trackeRdata}(model, data, melt = FALSE, ...) 9 | 10 | fortify_trackeRdata(model, data, melt = FALSE, ...) 11 | } 12 | \arguments{ 13 | \item{model}{The \code{\link{trackeRdata}} object.} 14 | 15 | \item{data}{Ignored.} 16 | 17 | \item{melt}{Logical. Should the data be melted into long format 18 | instead of the default wide format?} 19 | 20 | \item{...}{Ignored.} 21 | } 22 | \description{ 23 | Fortify a trackeRdata object for plotting with ggplot2 24 | } 25 | -------------------------------------------------------------------------------- /man/prettifyUnit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_plot.R 3 | \name{prettifyUnit} 4 | \alias{prettifyUnit} 5 | \alias{prettifyUnits} 6 | \title{Returns 'pretty' units for use for plotting or printing} 7 | \usage{ 8 | prettifyUnit(unit) 9 | 10 | prettifyUnits(unit) 11 | } 12 | \arguments{ 13 | \item{unit}{a unit as recorded in the \code{\link{data.frame}} 14 | generated by \code{\link{generate_units}}.} 15 | } 16 | \description{ 17 | Returns 'pretty' units for use for plotting or printing 18 | } 19 | \details{ 20 | \code{prettifyUnits} is the vectorized version of \code{prettifyUnit} 21 | } 22 | \examples{ 23 | prettifyUnit("m_per_s") 24 | prettifyUnit("rev_per_min") 25 | prettifyUnits(c("rev_per_min", "ft_per_min")) 26 | 27 | } 28 | -------------------------------------------------------------------------------- /man/fortify.distrProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R, R/zzz_aliases.R 3 | \name{fortify.distrProfile} 4 | \alias{fortify.distrProfile} 5 | \alias{fortify_distrProfile} 6 | \title{Fortify a distrProfile object for plotting with ggplot2.} 7 | \usage{ 8 | \method{fortify}{distrProfile}(model, data, melt = FALSE, ...) 9 | 10 | fortify_distrProfile(model, data, melt = FALSE, ...) 11 | } 12 | \arguments{ 13 | \item{model}{The \code{distrProfile} object.} 14 | 15 | \item{data}{Ignored.} 16 | 17 | \item{melt}{Logical. Should the data be melted into long format 18 | instead of the default wide format?} 19 | 20 | \item{...}{Ignored.} 21 | } 22 | \description{ 23 | Fortify a distrProfile object for plotting with ggplot2. 24 | } 25 | -------------------------------------------------------------------------------- /man/fortify.conProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R, R/zzz_aliases.R 3 | \name{fortify.conProfile} 4 | \alias{fortify.conProfile} 5 | \alias{fortify_conProfile} 6 | \title{Fortify a \code{\link{conProfile}} object for plotting with ggplot2.} 7 | \usage{ 8 | \method{fortify}{conProfile}(model, data, melt = FALSE, ...) 9 | 10 | fortify_conProfile(model, data, melt = FALSE, ...) 11 | } 12 | \arguments{ 13 | \item{model}{The \code{\link{conProfile}} object.} 14 | 15 | \item{data}{Ignored.} 16 | 17 | \item{melt}{Logical. Should the data be melted into long format 18 | instead of the default wide format?} 19 | 20 | \item{...}{Ignored.} 21 | } 22 | \description{ 23 | Fortify a \code{\link{conProfile}} object for plotting with ggplot2. 24 | } 25 | -------------------------------------------------------------------------------- /man/plot.trackeRdataZones.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_zones.R 3 | \name{plot.trackeRdataZones} 4 | \alias{plot.trackeRdataZones} 5 | \title{Plot training zones.} 6 | \usage{ 7 | \method{plot}{trackeRdataZones}(x, percent = TRUE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{trackeRdataZones} as returned by \code{\link{zones}}.} 11 | 12 | \item{percent}{Logical. Should the relative or absolute times spent training in the different zones be plotted?} 13 | 14 | \item{...}{Currently not used.} 15 | } 16 | \description{ 17 | Plot training zones. 18 | } 19 | \examples{ 20 | \dontrun{ 21 | data('run', package = 'trackeR') 22 | runZones <- zones(run, what = 'speed', breaks = c(0, 2:6, 12.5)) 23 | plot(runZones, percent = FALSE) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /man/fortify.trackeRWprime.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Wprime.R, R/zzz_aliases.R 3 | \name{fortify.trackeRWprime} 4 | \alias{fortify.trackeRWprime} 5 | \alias{fortify_trackeRWprime} 6 | \title{Fortify a trackeRWprime object for plotting with ggplot2.} 7 | \usage{ 8 | \method{fortify}{trackeRWprime}(model, data, melt = FALSE, ...) 9 | 10 | fortify_trackeRWprime(model, data, melt = FALSE, ...) 11 | } 12 | \arguments{ 13 | \item{model}{The \code{trackeRWprime} object as returned by \code{\link{Wprime}}.} 14 | 15 | \item{data}{Ignored.} 16 | 17 | \item{melt}{Logical. Should the data be melted into long format 18 | instead of the default wide format?} 19 | 20 | \item{...}{Ignored.} 21 | } 22 | \description{ 23 | Fortify a trackeRWprime object for plotting with ggplot2. 24 | } 25 | -------------------------------------------------------------------------------- /tests/testthat/test-zones.R: -------------------------------------------------------------------------------- 1 | context("implementation [zones, change_units]") 2 | 3 | data("runs", package = "trackeR") 4 | 5 | tol <- .Machine$double.eps 6 | 7 | test_that("zones method for trackeRdata objects [class, methods, output]", { 8 | expect_warning(z <- zones(runs, what = c("speed", "pace", "cadence_running", "heart_rate", "cadence_cyling", "asd"), 9 | unit_reference_sport = "cycling"), 10 | regexp = "asd|cadence_cycling") 11 | expect_true(all(c("speed", "pace", "cadence_running", "heart_rate") %in% names(z))) 12 | expect_true(inherits(z, "trackeRdataZones")) 13 | expect_equal(nsessions(z), 27, tolerance = tol) 14 | expect_equal(dim(get_units(z)), c(30, 3), tolerance = tol) 15 | expect_equal(attr(z, "unit_reference_sport"), "cycling", tolerance = tol) 16 | }) 17 | -------------------------------------------------------------------------------- /man/fortify.trackeRdataSummary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_summary.R, R/zzz_aliases.R 3 | \name{fortify.trackeRdataSummary} 4 | \alias{fortify.trackeRdataSummary} 5 | \alias{fortify_trackeRdataSummary} 6 | \title{Fortify a trackeRdataSummary object for plotting with ggplot2.} 7 | \usage{ 8 | \method{fortify}{trackeRdataSummary}(model, data, melt = FALSE, ...) 9 | 10 | fortify_trackeRdataSummary(model, data, melt = FALSE, ...) 11 | } 12 | \arguments{ 13 | \item{model}{The \code{\link{trackeRdata}} object.} 14 | 15 | \item{data}{Ignored.} 16 | 17 | \item{melt}{Logical. Should the data be melted into long format 18 | instead of the default wide format?} 19 | 20 | \item{...}{Currently not used.} 21 | } 22 | \description{ 23 | Fortify a trackeRdataSummary object for plotting with ggplot2. 24 | } 25 | -------------------------------------------------------------------------------- /man/compute_limits.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{compute_limits} 4 | \alias{compute_limits} 5 | \title{Compute variable limits from a \code{\link{trackeRdata}} object.} 6 | \usage{ 7 | compute_limits(object, a = 1e-04) 8 | } 9 | \arguments{ 10 | \item{object}{A \code{\link{trackeRdata}} object.} 11 | 12 | \item{a}{The levels at which quantiles will be computed are \code{a} 13 | and \code{1 - a}. Default is \code{a = 0.0001}.} 14 | } 15 | \description{ 16 | Compute variable limits from a \code{\link{trackeRdata}} object. 17 | } 18 | \details{ 19 | \code{compute_limits} computes limits by finding the \code{a} and 20 | \code{1 - a} quantiles for each variable in each session, and then 21 | taking the minimum and maximum of the \code{a} and \code{1 - a}, 22 | respectively, across sessions. 23 | } 24 | -------------------------------------------------------------------------------- /man/change_units.trackeRdataZones.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_zones.R 3 | \name{change_units.trackeRdataZones} 4 | \alias{change_units.trackeRdataZones} 5 | \title{Change the units of the variables in an \code{trackeRdataZones} object} 6 | \usage{ 7 | \method{change_units}{trackeRdataZones}(object, variable, unit, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{trackeRdataZones}.} 11 | 12 | \item{variable}{A vector of variables to be changed. Note, these are expected to be 13 | concepts like 'speed' rather than variable names like 'avgSpeed' or 'avgSpeedMoving'.} 14 | 15 | \item{unit}{A vector with the units, corresponding to variable.} 16 | 17 | \item{...}{Currently not used.} 18 | } 19 | \description{ 20 | Change the units of the variables in an \code{trackeRdataZones} object 21 | } 22 | -------------------------------------------------------------------------------- /man/change_units.trackeRdataSummary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_summary.R 3 | \name{change_units.trackeRdataSummary} 4 | \alias{change_units.trackeRdataSummary} 5 | \title{Change the units of the variables in an \code{trackeRdataSummary} object} 6 | \usage{ 7 | \method{change_units}{trackeRdataSummary}(object, variable, unit, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{trackeRdataSummary}.} 11 | 12 | \item{variable}{A vector of variables to be changed. Note, these are expected to be 13 | concepts like 'speed' rather than variable names like 'avgSpeed' or 'avgSpeedMoving'.} 14 | 15 | \item{unit}{A vector with the units, corresponding to variable.} 16 | 17 | \item{...}{Currently not used.} 18 | } 19 | \description{ 20 | Change the units of the variables in an \code{trackeRdataSummary} object 21 | } 22 | -------------------------------------------------------------------------------- /man/scaled.distrProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R 3 | \name{scaled.distrProfile} 4 | \alias{scaled.distrProfile} 5 | \title{Scale the distribution profile relative to its maximum value.} 6 | \usage{ 7 | \method{scaled}{distrProfile}(object, session = NULL, what = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{distrProfile} as returned by 11 | \code{\link{distributionProfile}}.} 12 | 13 | \item{session}{A numeric vector of the sessions to be selected and 14 | scaled. Defaults to all sessions.} 15 | 16 | \item{what}{A character version of the variables to be selected and 17 | scaled. Defaults to all variables in \code{object} (\code{what 18 | = NULL}).} 19 | 20 | \item{...}{Currently not used.} 21 | } 22 | \description{ 23 | Scale the distribution profile relative to its maximum value. 24 | } 25 | -------------------------------------------------------------------------------- /man/get_resting_periods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cleaning.R, R/zzz_aliases.R 3 | \name{get_resting_periods} 4 | \alias{get_resting_periods} 5 | \alias{restingPeriods} 6 | \title{Extract resting period characteristics} 7 | \usage{ 8 | get_resting_periods(times, session_threshold) 9 | 10 | restingPeriods(times, session_threshold) 11 | } 12 | \arguments{ 13 | \item{times}{Timestamps.} 14 | 15 | \item{session_threshold}{The threshold in hours for the time 16 | difference between consecutive timestamps above which they are 17 | considered to belong to different training sessions.} 18 | } 19 | \value{ 20 | A list containing a dataframe with start, end, and duration 21 | for each session and the resting time between sessions, named 22 | 'sessions' and 'restingTime', respectively. 23 | } 24 | \description{ 25 | Extract resting period characteristics 26 | } 27 | -------------------------------------------------------------------------------- /tests/testthat/test-extraction.R: -------------------------------------------------------------------------------- 1 | context("implementation [extraction utilities]") 2 | 3 | gpxfile_run <- system.file("extdata/gpx/", "20170708-154835-Run.gpx.gz", package = "trackeR") 4 | gpx <- readGPX(gpxfile_run) 5 | 6 | test_that("resting_periods returns the expected number of splits", { 7 | rp1 <- get_resting_periods(gpx$time, 2) 8 | rp2 <- get_resting_periods(gpx$time, 0.5/60) 9 | expect_equal(nrow(rp1$sessions), 1) 10 | expect_equal(nrow(rp2$sessions), 3) 11 | }) 12 | 13 | test_that("get_sessions splits the data correctly in multivariate zoo objects", { 14 | g1 <- get_sessions(gpx, 2) 15 | g2 <- get_sessions(gpx, 0.5/60) 16 | for (j in seq.int(length(g1))) { 17 | expect_is(g1[[j]], "zoo") 18 | } 19 | for (j in seq.int(length(g2))) { 20 | expect_is(g2[[j]], "zoo") 21 | } 22 | expect_true(all.equal(do.call("rbind", g2), g1[[1]], tolerance = 1e-12)) 23 | }) 24 | 25 | -------------------------------------------------------------------------------- /man/change_units.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata.R 3 | \name{change_units.trackeRdata} 4 | \alias{change_units.trackeRdata} 5 | \title{Change the units of the variables in an \code{trackeRdata} object} 6 | \usage{ 7 | \method{change_units}{trackeRdata}(object, variable, unit, sport, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{\link{trackeRdata}}.} 11 | 12 | \item{variable}{A vector of variables whose units are to be changed.} 13 | 14 | \item{unit}{A vector with the units, corresponding to \code{variable}.} 15 | 16 | \item{sport}{A vector of sports (among \code{'cycling'}, 17 | \code{'running'}, \code{'swimming'}) with each element 18 | corresponding to \code{variable} and \code{unit}.} 19 | 20 | \item{...}{Arguments to be passed to methods.} 21 | } 22 | \description{ 23 | Change the units of the variables in an \code{trackeRdata} object 24 | } 25 | -------------------------------------------------------------------------------- /man/nsessions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Wprime.R, R/distributionProfile.R, R/trackeR.R, 3 | % R/trackeRdata_summary.R 4 | \name{nsessions.trackeRWprime} 5 | \alias{nsessions.trackeRWprime} 6 | \alias{nsessions.distrProfile} 7 | \alias{nsessions.conProfile} 8 | \alias{nsessions} 9 | \alias{nsessions.trackeRdataSummary} 10 | \title{Generic function for calculating number of sessions} 11 | \usage{ 12 | \method{nsessions}{trackeRWprime}(object, ...) 13 | 14 | \method{nsessions}{distrProfile}(object, ...) 15 | 16 | \method{nsessions}{conProfile}(object, ...) 17 | 18 | nsessions(object, ...) 19 | 20 | \method{nsessions}{trackeRdataSummary}(object, ...) 21 | } 22 | \arguments{ 23 | \item{object}{The object for which to calculate the number of sessions.} 24 | 25 | \item{...}{Arguments to be passed to methods.} 26 | } 27 | \description{ 28 | Generic function for calculating number of sessions 29 | } 30 | -------------------------------------------------------------------------------- /man/session_times.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeR.R, R/trackeRdata.R, 3 | % R/trackeRdata_summary.R 4 | \name{session_times} 5 | \alias{session_times} 6 | \alias{session_times.trackeRdata} 7 | \alias{session_times.trackeRdataSummary} 8 | \title{Generic function for calculating session times} 9 | \usage{ 10 | session_times(object, session, duration_unit, ...) 11 | 12 | \method{session_times}{trackeRdata}(object, session = NULL, ...) 13 | 14 | \method{session_times}{trackeRdataSummary}(object, session = NULL, ...) 15 | } 16 | \arguments{ 17 | \item{object}{The object for which to calculate session start and end times.} 18 | 19 | \item{session}{The sessions for which to extract sports.} 20 | 21 | \item{duration_unit}{The unit durations should be returned.} 22 | 23 | \item{...}{Arguments to be passed to methods.} 24 | } 25 | \description{ 26 | Generic function for calculating session times 27 | } 28 | -------------------------------------------------------------------------------- /man/change_units.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeR.R, R/zzz_aliases.R 3 | \name{change_units} 4 | \alias{change_units} 5 | \alias{changeUnits} 6 | \title{Generic function for changing the units of measurement} 7 | \usage{ 8 | change_units(object, variable, unit, sport, ...) 9 | 10 | changeUnits(object, variable, unit, sport, ...) 11 | } 12 | \arguments{ 13 | \item{object}{The object of which the units of measurement are changed.} 14 | 15 | \item{variable}{A vector of variables whose units are to be changed.} 16 | 17 | \item{unit}{A vector with the units, corresponding to \code{variable}.} 18 | 19 | \item{sport}{A vector of sports (among \code{'cycling'}, 20 | \code{'running'}, \code{'swimming'}) with each element 21 | corresponding to \code{variable} and \code{unit}.} 22 | 23 | \item{...}{Arguments to be passed to methods.} 24 | } 25 | \description{ 26 | Generic function for changing the units of measurement 27 | } 28 | -------------------------------------------------------------------------------- /man/print.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata.R 3 | \name{print.trackeRdata} 4 | \alias{print.trackeRdata} 5 | \title{\code{\link{print}} method for \code{\link{trackeRdata}} objects} 6 | \usage{ 7 | \method{print}{trackeRdata}(x, duration_unit = "h", digits = 2, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{\link{trackeRdata}}.} 11 | 12 | \item{duration_unit}{The unit of duration in the resulting output. Default is \code{h} (hours).} 13 | 14 | \item{digits}{Number of digits to be printed.} 15 | 16 | \item{...}{Currently not used; only for compatibility with generic \code{\link{summary}} method only.} 17 | } 18 | \description{ 19 | \code{\link{print}} method for \code{\link{trackeRdata}} objects 20 | } 21 | \details{ 22 | The print method returns training coverage, number of sessions and 23 | total training duration from the data in the 24 | \code{\link{trackeRdata}} object. 25 | } 26 | -------------------------------------------------------------------------------- /man/change_units.trackeRthresholds.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/thresholds.R 3 | \name{change_units.trackeRthresholds} 4 | \alias{change_units.trackeRthresholds} 5 | \title{Change the units of the variables in an \code{trackeRthresholds} object} 6 | \usage{ 7 | \method{change_units}{trackeRthresholds}(object, variable, unit, sport, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{trackeRthresholds}.} 11 | 12 | \item{variable}{A vector of variables whose units are to be changed.} 13 | 14 | \item{unit}{A vector with the units, corresponding to \code{variable}.} 15 | 16 | \item{sport}{A vector of sports (among \code{'cycling'}, 17 | \code{'running'}, \code{'swimming'}) with each element 18 | corresponding to \code{variable} and \code{unit}.} 19 | 20 | \item{...}{Arguments to be passed to methods.} 21 | } 22 | \description{ 23 | Change the units of the variables in an \code{trackeRthresholds} object 24 | } 25 | -------------------------------------------------------------------------------- /man/plot.trackeRWprime.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Wprime.R 3 | \name{plot.trackeRWprime} 4 | \alias{plot.trackeRWprime} 5 | \title{Plot W'.} 6 | \usage{ 7 | \method{plot}{trackeRWprime}(x, session = NULL, dates = TRUE, scaled = TRUE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{trackeRWprime} as returned by \code{\link{Wprime}}.} 11 | 12 | \item{session}{A numeric vector of the sessions to be plotted, defaults to all sessions.} 13 | 14 | \item{dates}{Logical. Should the date of the session be used in the panel header?} 15 | 16 | \item{scaled}{Logical. Should the W' be scaled to the movement variable (power or speed) 17 | which is then plotted in the background?} 18 | 19 | \item{...}{Currently not used.} 20 | } 21 | \description{ 22 | Plot W'. 23 | } 24 | \examples{ 25 | \dontrun{ 26 | data('runs', package = 'trackeR') 27 | wexp <- Wprime(runs, session = 1:3, cp = 4, version = '2012') 28 | plot(wexp, session = 1:2) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /man/ridges.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_plot.R 3 | \name{ridges.trackeRdata} 4 | \alias{ridges.trackeRdata} 5 | \title{Ridgeline plots for \code{trackeRdata} objects} 6 | \usage{ 7 | \method{ridges}{trackeRdata}(x, session = NULL, what = "speed", smooth = TRUE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A \code{trackeRdata} object.} 11 | 12 | \item{session}{A numeric vector of the sessions to be used, 13 | defaults to all sessions.} 14 | 15 | \item{what}{The variables for which the distribution profiles 16 | should be generated. Defaults to all variables in 17 | \code{object} (\code{what = NULL}).} 18 | 19 | \item{smooth}{Logical. Should the concentration profiles be smoothed before plotting?} 20 | 21 | \item{...}{Currently not used.} 22 | } 23 | \description{ 24 | Ridgeline plots for \code{trackeRdata} objects 25 | } 26 | \examples{ 27 | 28 | \dontrun{ 29 | data('runs', package = 'trackeR') 30 | ridges(runs) 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /man/generate_thresholds.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/constants.R, R/zzz_aliases.R 3 | \name{generate_thresholds} 4 | \alias{generate_thresholds} 5 | \alias{generateDefaultThresholds} 6 | \title{Generate default thresholds.} 7 | \usage{ 8 | generate_thresholds(variable, lower, upper, sport, ...) 9 | 10 | generateDefaultThresholds(variable, lower, upper, sport, ...) 11 | } 12 | \arguments{ 13 | \item{variable}{A vector of variables with user-specified thresholds.} 14 | 15 | \item{lower}{A vector of lower limits corresponding to the elements of \code{variable}.} 16 | 17 | \item{upper}{A vector of upper limits corresponding to the elements of \code{variable}.} 18 | 19 | \item{sport}{A vector of sports (amongst \code{'cycling'}, 20 | \code{'running'}, \code{'swimming'}) with each element 21 | corresponding to \code{variable}, \code{lower} and \code{upper}.} 22 | 23 | \item{...}{Currently not used.} 24 | } 25 | \description{ 26 | Generate default thresholds. 27 | } 28 | -------------------------------------------------------------------------------- /man/smoother_control.distrProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R, R/zzz_aliases.R 3 | \name{smoother_control.distrProfile} 4 | \alias{smoother_control.distrProfile} 5 | \alias{smootherControl.distrProfile} 6 | \title{Auxiliary function for 7 | \code{\link{smoother.distrProfile}}. Typically used to construct a 8 | control argument for \code{\link{smoother.distrProfile}}.} 9 | \usage{ 10 | smoother_control.distrProfile(k = 30, sp = NULL, parallel = FALSE) 11 | 12 | smootherControl.distrProfile(k = 30, sp = NULL, parallel = FALSE) 13 | } 14 | \arguments{ 15 | \item{k}{Number of knots.} 16 | 17 | \item{sp}{A vector of smoothing parameters passed on to \code{\link[scam]{scam}}.} 18 | 19 | \item{parallel}{Logical. Should computation be carried out in 20 | parallel?} 21 | } 22 | \description{ 23 | Auxiliary function for 24 | \code{\link{smoother.distrProfile}}. Typically used to construct a 25 | control argument for \code{\link{smoother.distrProfile}}. 26 | } 27 | -------------------------------------------------------------------------------- /man/session_duration.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeR.R, R/trackeRdata.R, 3 | % R/trackeRdata_summary.R 4 | \name{session_duration} 5 | \alias{session_duration} 6 | \alias{session_duration.trackeRdata} 7 | \alias{session_duration.trackeRdataSummary} 8 | \title{Generic function for calculating session durations} 9 | \usage{ 10 | session_duration(object, session, duration_unit, ...) 11 | 12 | \method{session_duration}{trackeRdata}(object, session = NULL, duration_unit = "h", ...) 13 | 14 | \method{session_duration}{trackeRdataSummary}(object, session = NULL, ...) 15 | } 16 | \arguments{ 17 | \item{object}{The object for which to calculate session durations.} 18 | 19 | \item{session}{The sessions for which to extract sports.} 20 | 21 | \item{duration_unit}{The unit of duration.} 22 | 23 | \item{...}{Arguments to be passed to methods.} 24 | } 25 | \description{ 26 | Generic function for calculating session durations 27 | } 28 | \details{ 29 | The times units will be inherited from \code{object}. 30 | } 31 | -------------------------------------------------------------------------------- /man/decreasing_smoother.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R, R/zzz_aliases.R 3 | \name{decreasing_smoother} 4 | \alias{decreasing_smoother} 5 | \alias{decreasingSmoother} 6 | \title{Smooth a decreasing function.} 7 | \usage{ 8 | decreasing_smoother(x, y, k = 30, len = NULL, sp = NULL) 9 | 10 | decreasingSmoother(x, y, k = 30, len = NULL, sp = NULL) 11 | } 12 | \arguments{ 13 | \item{x}{The regressor passed on to the \code{formula} argument of \code{\link[scam]{scam}}.} 14 | 15 | \item{y}{The response passed on to the \code{formula} argument of \code{\link[scam]{scam}}.} 16 | 17 | \item{k}{Number of knots.} 18 | 19 | \item{len}{If \code{NULL}, the default, \code{x} is used for prediction. Otherwise, 20 | prediction is done over the range of \code{x} with \code{len} equidistant points.} 21 | 22 | \item{sp}{A vector of smoothing parameters passed on to \code{\link[scam]{scam}}.} 23 | } 24 | \description{ 25 | This smoother ensures a positive response that is a monotone decreasing function of x. 26 | } 27 | -------------------------------------------------------------------------------- /man/leaflet_route.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_plot.R, R/zzz_aliases.R 3 | \name{leaflet_route} 4 | \alias{leaflet_route} 5 | \alias{leafletRoute} 6 | \title{Plot routes for training sessions} 7 | \usage{ 8 | leaflet_route(x, session = NULL, threshold = TRUE, ...) 9 | 10 | leafletRoute(x, session = NULL, threshold = TRUE, ...) 11 | } 12 | \arguments{ 13 | \item{x}{A object of class \code{\link{trackeRdata}}.} 14 | 15 | \item{session}{A numeric vector of the sessions to be 16 | plotted. Defaults to all sessions.} 17 | 18 | \item{threshold}{Logical. Should thresholds be applied?} 19 | 20 | \item{...}{Additional arguments passed on to 21 | \code{\link{threshold}}.} 22 | } 23 | \description{ 24 | Plot the route ran/cycled during training on an interactive map. 25 | Internet connection is required to download the background map. 26 | Icons are by Maps Icons Collection \url{https://mapicons.mapsmarker.com} 27 | } 28 | \examples{ 29 | \dontrun{ 30 | data('runs', package = 'trackeR') 31 | leafletRoute(runs, session = 23:24) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /man/get_profile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R, R/trackeR.R 3 | \name{get_profile.distrProfile} 4 | \alias{get_profile.distrProfile} 5 | \alias{get_profile.conProfile} 6 | \alias{get_profile} 7 | \title{Generic function to subset distribution and concentration profiles} 8 | \usage{ 9 | \method{get_profile}{distrProfile}(object, session = NULL, what = NULL, ...) 10 | 11 | \method{get_profile}{conProfile}(object, session = NULL, what = NULL, ...) 12 | 13 | get_profile(object, session, what, ...) 14 | } 15 | \arguments{ 16 | \item{object}{An object of class \code{distrProfile} or \code{conProfile} 17 | as returned by \code{\link{distribution_profile}} and 18 | \code{\link{concentration_profile}}, respectively.} 19 | 20 | \item{session}{A numeric vector of the sessions to selected. 21 | Defaults to all sessions.} 22 | 23 | \item{what}{A character version of the variables to be 24 | selected. Defaults to all variables in \code{object} 25 | (\code{what = NULL}).} 26 | 27 | \item{...}{Current no used.} 28 | } 29 | \description{ 30 | Generic function to subset distribution and concentration profiles 31 | } 32 | -------------------------------------------------------------------------------- /man/ridges.distrProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R 3 | \name{ridges.distrProfile} 4 | \alias{ridges.distrProfile} 5 | \title{Ridgeline plots for \code{distrProfile} objects} 6 | \usage{ 7 | \method{ridges}{distrProfile}(x, session = NULL, what = NULL, smooth = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{distrProfile} as returned by 11 | \code{\link{distribution_profile}}.} 12 | 13 | \item{session}{A numeric vector of the sessions to be plotted, 14 | defaults to all sessions.} 15 | 16 | \item{what}{Which variables should be plotted? Defaults to all 17 | variables in \code{object} (\code{what = NULL}).} 18 | 19 | \item{smooth}{Logical. Should unsmoothed profiles be smoothed 20 | before plotting?} 21 | 22 | \item{...}{Further arguments to be passed to 23 | \code{\link{smoother_control.distrProfile}}.} 24 | } 25 | \description{ 26 | Ridgeline plots for \code{distrProfile} objects 27 | } 28 | \examples{ 29 | \dontrun{ 30 | 31 | data('runs', package = 'trackeR') 32 | dProfile <- distribution_profile(runs, what = c("speed", "heart_rate")) 33 | ridges(dProfile) 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /man/get_sport.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Wprime.R, R/concentrationProfile.R, 3 | % R/distributionProfile.R, R/trackeR.R, R/trackeRdata.R, 4 | % R/trackeRdata_summary.R 5 | \name{get_sport.trackeRWprime} 6 | \alias{get_sport.trackeRWprime} 7 | \alias{get_sport.conProfile} 8 | \alias{get_sport.distrProfile} 9 | \alias{get_sport} 10 | \alias{get_sport.trackeRdata} 11 | \alias{get_sport.trackeRdataSummary} 12 | \title{Generic function for extracting sports} 13 | \usage{ 14 | \method{get_sport}{trackeRWprime}(object, ...) 15 | 16 | \method{get_sport}{conProfile}(object, session = NULL, ...) 17 | 18 | \method{get_sport}{distrProfile}(object, session = NULL, ...) 19 | 20 | get_sport(object, session, ...) 21 | 22 | \method{get_sport}{trackeRdata}(object, session = NULL, ...) 23 | 24 | \method{get_sport}{trackeRdataSummary}(object, session = NULL, ...) 25 | } 26 | \arguments{ 27 | \item{object}{The object from which to extract sports.} 28 | 29 | \item{...}{Arguments to be passed to methods.} 30 | 31 | \item{session}{The sessions for which to extract sports.} 32 | } 33 | \description{ 34 | Generic function for extracting sports 35 | } 36 | -------------------------------------------------------------------------------- /man/ridges.conProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/concentrationProfile.R 3 | \name{ridges.conProfile} 4 | \alias{ridges.conProfile} 5 | \title{Ridgeline plots for \code{distrProfile} objects} 6 | \usage{ 7 | \method{ridges}{conProfile}(x, session = NULL, what = NULL, smooth = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{conProfile} as returned by 11 | \code{\link{concentration_profile}}.} 12 | 13 | \item{session}{A numeric vector of the sessions to be plotted, 14 | defaults to all sessions.} 15 | 16 | \item{what}{Which variables should be plotted? Defaults to all 17 | variables in \code{object} (\code{what = NULL}).} 18 | 19 | \item{smooth}{Logical. Should unsmoothed profiles be smoothed 20 | before plotting?} 21 | 22 | \item{...}{Further arguments to be passed to 23 | \code{\link{smoother_control.distrProfile}}.} 24 | } 25 | \description{ 26 | Ridgeline plots for \code{distrProfile} objects 27 | } 28 | \examples{ 29 | \dontrun{ 30 | 31 | data('runs', package = 'trackeR') 32 | dProfile <- distributionProfile(runs, what = c('speed', 'heart_rate')) 33 | cProfile <- concentrationProfile(dProfile) 34 | ridges(cProfile, what = "speed") 35 | ridges(cProfile, what = "heart_rate") 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /man/get_elevation_gain.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{get_elevation_gain} 4 | \alias{get_elevation_gain} 5 | \title{(Cumulative) Elevation gain.} 6 | \usage{ 7 | get_elevation_gain( 8 | object, 9 | smooth = FALSE, 10 | cumulative = FALSE, 11 | vertical_noise = 0 12 | ) 13 | } 14 | \arguments{ 15 | \item{object}{A (univariate) zoo object.} 16 | 17 | \item{smooth}{Logical. Should the elevation be smoothed? Default is 18 | \code{TRUE}.} 19 | 20 | \item{cumulative}{Logical. Return the cumulative elevation gain 21 | (\code{FALSE}; default) or just the elevation gain?} 22 | 23 | \item{vertical_noise}{A scalar. Absolute elevation gains less that 24 | \code{vertical_noise} are set to zero. Default is \code{0}.} 25 | } 26 | \description{ 27 | (Cumulative) Elevation gain. 28 | } 29 | \details{ 30 | The elevation gain is defined here as the difference in altitude 31 | between two consecutive observations. If \code{cumulative = FALSE} 32 | then the elevation gain is returned, otherwise any elevation loses 33 | (i.e. negative elevation gain) are ignored and the cumulative 34 | elevation gain is returned. If \code{smooth = TRUE} then the 35 | elevation gain will be smoothed using a spline smoother before 36 | either returning it or computing cumulative elevation gains. 37 | } 38 | -------------------------------------------------------------------------------- /man/smoother.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_smoother.R 3 | \name{smoother.trackeRdata} 4 | \alias{smoother.trackeRdata} 5 | \title{Smoother for \code{\link{trackeRdata}} objects.} 6 | \usage{ 7 | \method{smoother}{trackeRdata}(object, session = NULL, control = list(...), ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{\link{trackeRdata}}.} 11 | 12 | \item{session}{The sessions to be smoothed. Default is all sessions.} 13 | 14 | \item{control}{A list of parameters for controlling the smoothing 15 | process. This is passed to \code{\link{smoother_control.trackeRdata}}.} 16 | 17 | \item{...}{Arguments to be used to form the default \code{control} 18 | argument if it is not supplied directly.} 19 | } 20 | \value{ 21 | An object of class \code{\link{trackeRdata}}. 22 | } 23 | \description{ 24 | Smoother for \code{\link{trackeRdata}} objects. 25 | } 26 | \examples{ 27 | \dontrun{ 28 | data('run', package = 'trackeR') 29 | ## unsmoothed speeds 30 | plot(run, smooth = FALSE) 31 | ## default smoothing 32 | plot(run, smooth = TRUE) 33 | ## smoothed with some non-default options 34 | runS <- smoother(run, fun = 'median', width = 20, what = 'speed') 35 | plot(runS, smooth = FALSE) 36 | } 37 | } 38 | \seealso{ 39 | \code{\link{smoother_control.trackeRdata}} 40 | } 41 | -------------------------------------------------------------------------------- /man/plot.conProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/concentrationProfile.R 3 | \name{plot.conProfile} 4 | \alias{plot.conProfile} 5 | \title{Plot concentration profiles.} 6 | \usage{ 7 | \method{plot}{conProfile}(x, session = NULL, what = NULL, multiple = FALSE, smooth = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{conProfile} as returned by 11 | \code{\link{concentration_profile}}.} 12 | 13 | \item{session}{A numeric vector of the sessions to be plotted, 14 | defaults to all sessions.} 15 | 16 | \item{what}{Which variables should be plotted? Defaults to all 17 | variables in \code{object} (\code{what = NULL}).} 18 | 19 | \item{multiple}{Logical. Should all sessions be plotted in one 20 | panel?} 21 | 22 | \item{smooth}{Logical. Should unsmoothed profiles be smoothed 23 | before plotting?} 24 | 25 | \item{...}{Further arguments to be passed to 26 | \code{\link{smoother_control.distrProfile}}.} 27 | } 28 | \description{ 29 | Plot concentration profiles. 30 | } 31 | \examples{ 32 | data('runs', package = 'trackeR') 33 | dProfile <- distributionProfile(runs, session = 1:3, what = 'speed', 34 | grid = seq(0, 12.5, by = 0.05)) 35 | cProfile <- concentrationProfile(dProfile) 36 | \dontrun{ 37 | plot(cProfile, smooth = FALSE) 38 | plot(cProfile) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /man/plot.distrProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R 3 | \name{plot.distrProfile} 4 | \alias{plot.distrProfile} 5 | \title{Plot distribution profiles.} 6 | \usage{ 7 | \method{plot}{distrProfile}(x, session = NULL, what = NULL, multiple = FALSE, smooth = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{distrProfile} as returned by 11 | \code{\link{distribution_profile}}.} 12 | 13 | \item{session}{A numeric vector of the sessions to be plotted, 14 | defaults to all sessions.} 15 | 16 | \item{what}{Which variables should be plotted? Defaults to all 17 | variables in \code{object} (\code{what = NULL}).} 18 | 19 | \item{multiple}{Logical. Should all sessions be plotted in one 20 | panel?} 21 | 22 | \item{smooth}{Logical. Should unsmoothed profiles be smoothed 23 | before plotting?} 24 | 25 | \item{...}{Further arguments to be passed to 26 | \code{\link{smoother_control.distrProfile}}.} 27 | } 28 | \description{ 29 | Plot distribution profiles. 30 | } 31 | \examples{ 32 | \dontrun{ 33 | data('runs', package = 'trackeR') 34 | dProfile <- distribution_profile(runs, session = 1:2, 35 | what = "speed", grid = seq(0, 12.5, by = 0.05)) 36 | plot(dProfile, smooth = FALSE) 37 | plot(dProfile, smooth = FALSE, multiple = TRUE) 38 | plot(dProfile, multiple = TRUE) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /man/prepare_route.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_plot.R 3 | \name{prepare_route} 4 | \alias{prepare_route} 5 | \title{Prepare a \code{\link{data.frame}} for use in 6 | \code{\link{leaflet_route}} and \code{\link{plot_route}}} 7 | \usage{ 8 | prepare_route(x, session = 1, threshold = TRUE, ...) 9 | } 10 | \arguments{ 11 | \item{x}{a \code{\link{trackeRdata}} object.} 12 | 13 | \item{session}{which session to prepare the 14 | \code{\link{data.frame}} for?} 15 | 16 | \item{threshold}{if \code{TRUE} (default), then thresholds are 17 | applied to \code{x} prior to preparing the 18 | \code{\link{data.frame}}.} 19 | 20 | \item{...}{Additional arguments to be passed to 21 | \code{\link{threshold}}.} 22 | } 23 | \value{ 24 | A \code{data.frame} with variables \code{longitude}, 25 | \code{latitude}, \code{speed}, \code{SessionID}, \code{longitude0}, 26 | \code{longitude1}, \code{latitude0}, \code{latitude1}. The 27 | observations are ordered according to the timestamp they have in 28 | \code{x}. A suffix of 0 indicates 'start' and a suffix of 1 29 | indicates 'end' at any given observation. 30 | } 31 | \description{ 32 | Prepare a \code{\link{data.frame}} for use in 33 | \code{\link{leaflet_route}} and \code{\link{plot_route}} 34 | } 35 | \details{ 36 | To be used internally in mapping function and rarely by the user. 37 | } 38 | -------------------------------------------------------------------------------- /man/smoother.conProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/concentrationProfile.R 3 | \name{smoother.conProfile} 4 | \alias{smoother.conProfile} 5 | \title{Smoother for concentration profiles.} 6 | \usage{ 7 | \method{smoother}{conProfile}(object, session = NULL, what = NULL, control = list(...), ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{conProfile} as returned by 11 | \code{\link{concentration_profile}}.} 12 | 13 | \item{session}{A numeric vector of the sessions to be selected and 14 | smoothed. Defaults to all sessions.} 15 | 16 | \item{what}{A character version of the variables to be selected and 17 | smoothed. Defaults to all variables in \code{object} 18 | (\code{what = NULL}).} 19 | 20 | \item{control}{A list of parameters for controlling the smoothing 21 | process. This is passed to 22 | \code{\link{smoother_control.distrProfile}}.} 23 | 24 | \item{...}{Arguments to be used to form the default \code{control} 25 | argument if it is not supplied directly.} 26 | } 27 | \description{ 28 | To ensure positivity of the smoothed concentration profiles, the 29 | concentration profiles are transformed to distribution profiles 30 | before smoothing. The smoothed distribution profiles are then 31 | transformed to concentration profiles. 32 | } 33 | \seealso{ 34 | \code{\link{smoother_control.distrProfile}} 35 | } 36 | -------------------------------------------------------------------------------- /data-raw/sticker.R: -------------------------------------------------------------------------------- 1 | library("hexSticker") 2 | library("png") 3 | library("grid") 4 | library("ggplot2") 5 | 6 | 7 | 8 | 9 | 10 | "#FF94B7" 11 | "#FFB32F" 12 | "#B6D000" 13 | "#00E380" 14 | "#00E6E6" 15 | "#28CFFF" 16 | "#F3A2FF" 17 | 18 | 19 | g2 <- readPNG(system.file("icons", "man-running.png", package = "trackeRapp")) 20 | g2 <- matrix(rgb(g2[,,1], g2[,,2], g2[,,3], g2[,,4] * 0.5), nrow = dim(g2)[1]) 21 | g2 <- rasterGrob(g2, interpolate = TRUE) 22 | 23 | gg <- qplot(c(2, 3), c(2, 3.2), geom = "blank") + 24 | annotation_custom(g2, xmin = 2, xmax = 3, ymin = 2, ymax = 2.9) + 25 | geom_text(aes(x = 2.68, y = 3.07, label = "app", vjust = 0, hjust = 0), color = "white", size = 5) + 26 | theme_minimal() + 27 | theme(axis.title.x = element_blank(), 28 | axis.text.x = element_blank(), 29 | axis.ticks.x = element_blank(), 30 | axis.title.y = element_blank(), 31 | axis.text.y = element_blank(), 32 | axis.ticks.y = element_blank(), 33 | panel.grid.major = element_blank(), 34 | panel.grid.minor = element_blank(), 35 | legend.position = NULL) 36 | sticker(gg, 37 | package="trackeR", 38 | p_size = 8, s_x = 1, s_y = .8, s_width = 1.4, s_height = 1, 39 | p_color = "white", 40 | h_color = "#0570b0", 41 | h_fill = "#0099CC", 42 | filename="~/Downloads/baseplot.png") 43 | 44 | -------------------------------------------------------------------------------- /man/compute_breaks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{compute_breaks} 4 | \alias{compute_breaks} 5 | \title{Compute a grid of breakpoints per variable from a \code{\link{trackeRdata}} object.} 6 | \usage{ 7 | compute_breaks( 8 | object, 9 | a = 1e-04, 10 | n_breaks = 9, 11 | limits = NULL, 12 | what = c("speed", "heart_rate") 13 | ) 14 | } 15 | \arguments{ 16 | \item{object}{A \code{\link{trackeRdata}} object.} 17 | 18 | \item{a}{The levels at which quantiles will be computed are 19 | \code{a} and \code{1 - a}. Default is \code{a = 0.0001}.} 20 | 21 | \item{n_breaks}{A scalar determining the number of breakpoints to 22 | be computed} 23 | 24 | \item{limits}{A list of a vectors, each specifying the lower and 25 | upper limit for each variable to be used when computing the 26 | grid. Default is \code{NULL}, in which case 27 | \code{\link{compute_limits}} is used.} 28 | 29 | \item{what}{The variables for which a grid of breakpoints should be 30 | computed. Defaults to \code{c("speed", "heart_rate")}.} 31 | } 32 | \value{ 33 | A named list with names as in \code{what}, with elements the grids 34 | of breakpoints per variable. 35 | } 36 | \description{ 37 | Compute a grid of breakpoints per variable from a \code{\link{trackeRdata}} object. 38 | } 39 | \examples{ 40 | data("runs") 41 | compute_breaks(runs, what = c("speed", "heart_rate", "altitude")) 42 | } 43 | -------------------------------------------------------------------------------- /man/profile2fd.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fda.R 3 | \name{profile2fd} 4 | \alias{profile2fd} 5 | \title{Transform distribution and concentration profiles to functional data objects of class fd.} 6 | \usage{ 7 | profile2fd(object, what, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{distrProfile} or \code{conProfile}, as returned by \code{\link{distributionProfile}} and \code{\link{concentrationProfile}}, respectively.} 11 | 12 | \item{what}{The variable for which the profiles should be transformed to a functional data object.} 13 | 14 | \item{...}{Additional arguments passed on to \code{\link[fda]{Data2fd}}} 15 | } 16 | \value{ 17 | An object of class \code{\link[fda]{fd}}. 18 | } 19 | \description{ 20 | Transform distribution and concentration profiles to functional data objects of class fd. 21 | } 22 | \examples{ 23 | \dontrun{ 24 | library('fda') 25 | data('runs', package = 'trackeR') 26 | dp <- distributionProfile(runs, what = 'speed') 27 | dpFun <- profile2fd(dp, what = 'speed', 28 | fdnames = list('speed', 'sessions', 'time above threshold')) 29 | dp.pca <- pca.fd(dpFun, nharm = 4) 30 | ## 1st harmonic captures vast majority of the variation 31 | dp.pca$varprop 32 | ## time spent above speed = 0 is the characteristic distinguishing the profiles 33 | plot(dp.pca, harm = 1) 34 | sumRuns <- summary(runs) 35 | plot(sumRuns$durationMoving, dp.pca$scores[,1]) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /inst/WORDLIST: -------------------------------------------------------------------------------- 1 | Achim 2 | ArXiv 3 | BW 4 | Bohannon 5 | Celcius 6 | Chidnok 7 | Downie 8 | EPSRC 9 | Endomondo 10 | GPSports 11 | GPX 12 | Garmin 13 | HH 14 | Inf 15 | JSS 16 | Modeling 17 | Monod 18 | ORCID 19 | OpenStreetMap 20 | PF 21 | POSIXct 22 | Passfield 23 | Poisson 24 | Pya 25 | RW 26 | Ridgeline 27 | Rosenblatt 28 | Runtastic 29 | SQLite 30 | SRTM 31 | STIDF 32 | Scherrer 33 | Skiba 34 | SportsAnalytics 35 | Strava 36 | TCX 37 | Vanhatalo 38 | Verlag 39 | Wprime 40 | W’ 41 | XT 42 | Zeileis 43 | adehabtitatLT 44 | avgSpeed 45 | avgSpeedMoving 46 | bz 47 | center 48 | changeUnits 49 | conProfile 50 | concentrationProfile 51 | cumsum 52 | cycleRtools 53 | dat 54 | db 55 | dialinecolor 56 | distrProfile 57 | distributionProfile 58 | doi 59 | etc 60 | fd 61 | fda 62 | foreach 63 | funPCA 64 | getUnits 65 | ggmap 66 | ggplot 67 | github 68 | gpx 69 | gz 70 | json 71 | jss 72 | leafletPlot 73 | leafletRoute 74 | lgap 75 | lskip 76 | multisport 77 | nsessions 78 | ombined 79 | plotRoute 80 | readContainer 81 | readDB 82 | readDirectory 83 | readGPX 84 | readJSON 85 | readTCX 86 | reexpressing 87 | regex 88 | restingTime 89 | ridgeline 90 | runDF 91 | runSummary 92 | runsSummary 93 | spacetime 94 | tcx 95 | thethreshold 96 | timezone 97 | trackeRWprime 98 | trackeRdata 99 | trackeRdataSummary 100 | trackeRdataZones 101 | trackeRfpca 102 | un 103 | unitNew 104 | unitOld 105 | unsmoothed 106 | varprop 107 | xz 108 | za 109 | -------------------------------------------------------------------------------- /man/timeline.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeR.R, R/trackeRdata_plot.R, 3 | % R/trackeRdata_summary.R 4 | \name{timeline} 5 | \alias{timeline} 6 | \alias{timeline.trackeRdata} 7 | \alias{timeline.trackeRdataSummary} 8 | \title{Generic function for visualising the sessions on a time versus date plot} 9 | \usage{ 10 | timeline(object, lims, ...) 11 | 12 | \method{timeline}{trackeRdata}(object, lims = NULL, ...) 13 | 14 | \method{timeline}{trackeRdataSummary}(object, lims = NULL, ...) 15 | } 16 | \arguments{ 17 | \item{object}{An object of class \code{\link{trackeRdata}} or 18 | \code{\link{trackeRdataSummary}}.} 19 | 20 | \item{lims}{An optional vector of two times in HH:MM 21 | format. Default is \code{NULL} If supplied, the times are used 22 | to define the limits of the time axis.} 23 | 24 | \item{...}{Arguments passed to \code{\link{summary.trackeRdata}}.} 25 | } 26 | \description{ 27 | Generic function for visualising the sessions on a time versus date plot 28 | 29 | Timeline plot for \code{\link{trackeRdata}} objects. 30 | 31 | Timeline plot for \code{\link{trackeRdataSummary}} objects 32 | } 33 | \examples{ 34 | \dontrun{ 35 | data('runs', package = 'trackeR') 36 | ## timeline plot applied on the \code{trackeRdata} object directly and with 37 | ## inferred limits for the time axis 38 | timeline(runs) 39 | 40 | ## the same timeline plot applied on the \code{trackeRdataSummary} object 41 | runSummary <- summary(runs) 42 | timeline(runSummary, lims = c('00:01', '23:59')) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /man/plot.trackeRfpca.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fda.R 3 | \name{plot.trackeRfpca} 4 | \alias{plot.trackeRfpca} 5 | \title{Plot function for functional principal components analysis of distribution and concentration profiles.} 6 | \usage{ 7 | \method{plot}{trackeRfpca}(x, harm = NULL, expand = NULL, pointplot = TRUE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{trackeRfpca} as returned by \code{\link{funPCA}}.} 11 | 12 | \item{harm}{A numerical vector of the harmonics to be plotted. Defaults to all harmonics.} 13 | 14 | \item{expand}{The factor used to generate suitable multiples of the harmonics. 15 | If \code{NULL}, the effect of +/- 2 standard deviations of each harmonic is plotted.} 16 | 17 | \item{pointplot}{Should the harmonics be plotted with \code{+} and \code{-} 18 | point characters? Otherwise, lines are used.} 19 | 20 | \item{...}{Currently not used.} 21 | } 22 | \description{ 23 | Plot function for functional principal components analysis of distribution and concentration profiles. 24 | } 25 | \examples{ 26 | \dontrun{ 27 | data('runs', package = 'trackeR') 28 | dp <- distributionProfile(runs, what = 'speed') 29 | dp.pca <- funPCA(dp, what = 'speed', nharm = 4) 30 | ## 1st harmonic captures vast majority of the variation 31 | plot(dp.pca) 32 | plot(dp.pca, harm = 1, pointplot = FALSE) 33 | } 34 | } 35 | \references{ 36 | Ramsay JO, Silverman BW (2005). Functional Data Analysis. Springer-Verlag New York. 37 | } 38 | \seealso{ 39 | \code{\link[fda]{plot.pca.fd}} 40 | } 41 | -------------------------------------------------------------------------------- /data-raw/run.R: -------------------------------------------------------------------------------- 1 | filepath <- system.file("extdata/tcx", "2013-06-30-084200.TCX", package = "trackeR") 2 | run <- read_container(filepath, 3 | type = "tcx", 4 | timezone = "GMT", 5 | session_threshold = 2, 6 | country = NULL, 7 | mask = TRUE, 8 | from_distances = NULL, 9 | speedunit = NULL, 10 | distanceunit = NULL, 11 | lgap = 30, 12 | lskip = 5, 13 | m = 11) 14 | save(run, file = "data/run.rda", compress = "xz") 15 | 16 | ## all of June = 33 files, 27 sessions 17 | filedir <- system.file("extdata/tcx", package = "trackeR") ## needs to point to git folder 18 | runs <- readDirectory(filedir, 19 | aggregate = TRUE, 20 | table = "gps_data", 21 | timezone = "", 22 | session_threshold = 1.5, ## not the default, splits session 20 23 | country = NULL, 24 | mask = TRUE, 25 | from_distances = NULL, 26 | speedunit = list(tcx = "m_per_s", db3 = "km_per_h", json = "km_per_h"), 27 | distanceunit = list(tcx = "m", db3 = "km", json = "km"), 28 | lgap = 30, 29 | lskip = 5, 30 | m = 11, 31 | verbose = TRUE, 32 | silent = FALSE) 33 | save(runs, file = "data/runs.rda", compress = "xz") 34 | -------------------------------------------------------------------------------- /man/plot.trackeRdataSummary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_summary.R 3 | \name{plot.trackeRdataSummary} 4 | \alias{plot.trackeRdataSummary} 5 | \title{Plot an object of class \code{\link{trackeRdataSummary}}.} 6 | \usage{ 7 | \method{plot}{trackeRdataSummary}(x, date = TRUE, what = NULL, group = NULL, trend = TRUE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{trackeRdataSummary}.} 11 | 12 | \item{date}{Should the date or the session number be used on the abscissa?} 13 | 14 | \item{what}{Name of variables which should be plotted. Default is all. A vector with at least one of \code{"distance"}, \code{"duration"}, \code{"avgSpeed"}, \code{"avgPace"}, \code{"avgCadenceRunning"}, \code{"avgCadenceCycling"}, \code{"avgAltitude"}, \code{"avgPower"}, \code{"avgHeartRate"}, \code{"avgTemperature"}, \code{"wrRatio"}, \code{"total_elevation_gain"}, and \code{NULL}, in which case all variables are plotted.} 15 | 16 | \item{group}{Which group of variables should be plotted? This can either be 17 | \code{total} or \code{moving}. Default is both.} 18 | 19 | \item{trend}{Should a smooth trend be plotted?} 20 | 21 | \item{...}{Currently not used.} 22 | } 23 | \description{ 24 | Plot an object of class \code{\link{trackeRdataSummary}}. 25 | } 26 | \examples{ 27 | \dontrun{ 28 | data('runs', package = 'trackeR') 29 | runSummary <- summary(runs) 30 | plot(runSummary) 31 | plot(runSummary, date = FALSE, group = 'total', 32 | what = c('distance', 'duration', 'avgSpeed')) 33 | } 34 | } 35 | \seealso{ 36 | \code{\link{summary.trackeRdata}} 37 | } 38 | -------------------------------------------------------------------------------- /tests/testthat/test-cleaning.R: -------------------------------------------------------------------------------- 1 | context("implementation [sanity checks, distance correction, imputation of speeds]") 2 | 3 | tcxfile <- system.file("extdata/tcx/", "2013-06-30-070511.TCX.gz", package = "trackeR") 4 | gpxfile_ride <- system.file("extdata/gpx/", "20170709-151453-Ride.gpx.gz", package = "trackeR") 5 | 6 | tcx <- readTCX(tcxfile) 7 | test_that("sanity_checks returns warning [silent = FALSE] and removes duplicates", { 8 | expect_warning(tcx_c <- sanity_checks(tcx, silent = FALSE)) 9 | expect_true(any(duplicated(tcx$time))) 10 | expect_false(any(duplicated(tcx_c$time))) 11 | }) 12 | 13 | gpx <- readGPX(gpxfile_ride) 14 | test_that("distance correction works", { 15 | gpx_c <- distance_correction(gpx) 16 | expect_gt(max(na.omit(gpx_c$distance)), max(gpx$distance)) 17 | }) 18 | 19 | 20 | test_that("impute_speeds imputes speeds and imputes power [sport = 'cycling']", { 21 | s0 <- sanity_checks(gpx, silent = TRUE) 22 | s1 <- get_sessions(s0) 23 | s2 <- impute_speeds(s1[[1]], from_distances = TRUE, sport = "cycling") 24 | s3 <- impute_speeds(s1[[1]], from_distances = TRUE, sport = "running") 25 | expect_true(all(is.na(s1[[1]]$speed))) 26 | expect_true(all(!is.na(s2$speed))) 27 | expect_true(all(is.na(s2$power))) 28 | expect_true(all(is.na(s3$power))) 29 | }) 30 | 31 | test_that("impute_speeds imputes power ", { 32 | s0 <- sanity_checks(gpx, silent = TRUE) 33 | s1 <- get_sessions(s0) 34 | s2 <- impute_speeds(s1[[1]], from_distances = TRUE) 35 | expect_true(all(is.na(head(s1[[1]]$speed)))) 36 | expect_true(all(!is.na(head(s2$speed)))) 37 | }) 38 | 39 | -------------------------------------------------------------------------------- /tests/testthat/test-generate.R: -------------------------------------------------------------------------------- 1 | context("implementation [generation of variable names, base units and thresholds]") 2 | 3 | test_that("variable names are generated correctly", { 4 | g <- generate_variable_names() 5 | expect_true(all(c("time", "latitude", "longitude", "altitude", 6 | "distance", "heart_rate", "speed", "cadence_running", 7 | "cadence_cycling", "power", "temperature") %in% g$human_names)) 8 | }) 9 | 10 | test_that("variables are generated correctly", { 11 | g <- generate_units() 12 | expect_equal(g[g$variable == "longitude", "unit"], rep("degree", 3)) 13 | expect_equal(g[g$variable == "latitude", "unit"], rep("degree", 3)) 14 | expect_equal(g[g$variable == "altitude", "unit"], rep("m", 3)) 15 | expect_equal(g[g$variable == "distance", "unit"], rep("m", 3)) 16 | expect_equal(g[g$variable == "heart_rate", "unit"], rep("bpm", 3)) 17 | expect_equal(g[g$variable == "speed", "unit"], rep("m_per_s", 3)) 18 | expect_equal(g[g$variable == "cadence_running", "unit"], rep("steps_per_min", 1)) 19 | expect_equal(g[g$variable == "cadence_cycling", "unit"], rep("rev_per_min", 1)) 20 | expect_equal(g[g$variable == "power", "unit"], rep("W", 1)) 21 | expect_equal(g[g$variable == "temperature", "unit"], rep("C", 3)) 22 | expect_equal(g[g$variable == "pace", "unit"], rep("min_per_km", 3)) 23 | expect_equal(g[g$variable == "duration", "unit"], rep("min", 3)) 24 | }) 25 | 26 | test_that("thresholds are generated correctly", { 27 | g <- generate_thresholds() 28 | expect_true(all(c("variable", "unit", "lower", "upper", "sport") %in% names(g))) 29 | }) 30 | 31 | 32 | -------------------------------------------------------------------------------- /man/funPCA.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fda.R, R/trackeR.R 3 | \name{funPCA} 4 | \alias{funPCA} 5 | \alias{funPCA.distrProfile} 6 | \alias{funPCA.conProfile} 7 | \title{Functional principal components analysis of distribution or concentration profiles.} 8 | \usage{ 9 | \method{funPCA}{distrProfile}(object, what, nharm = 4, ...) 10 | 11 | \method{funPCA}{conProfile}(object, what, nharm = 4, ...) 12 | 13 | funPCA(object, ...) 14 | } 15 | \arguments{ 16 | \item{object}{The object to which a functional principal components 17 | analysis is applied.} 18 | 19 | \item{what}{The variable for which the profiles should be analysed.} 20 | 21 | \item{nharm}{The number of principal components estimated.} 22 | 23 | \item{...}{Arguments to be passed to methods.} 24 | } 25 | \value{ 26 | An object of class \code{trackeRfpca}. 27 | } 28 | \description{ 29 | Functional principal components analysis of distribution or concentration profiles. 30 | 31 | Generic function for functional principal components analysis 32 | } 33 | \details{ 34 | The \code{...} argument is passed on to \code{\link[fda]{pca.fd}}. 35 | } 36 | \examples{ 37 | \dontrun{ 38 | data('runs', package = 'trackeR') 39 | dp <- distributionProfile(runs, what = 'speed') 40 | dp.pca <- funPCA(dp, what = 'speed', nharm = 4) 41 | ## 1st harmonic captures vast majority of the variation 42 | plot(dp.pca, harm = 1) 43 | ## time spent above speed = 0 is the characteristic distinguishing the profiles 44 | sumRuns <- summary(runs) 45 | plot(sumRuns$durationMoving, dp.pca$scores[,1]) 46 | } 47 | } 48 | \references{ 49 | Ramsay JO, Silverman BW (2005). Functional Data Analysis. Springer-Verlag New York. 50 | } 51 | -------------------------------------------------------------------------------- /man/concentration_profile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeR.R, R/zzz_aliases.R 3 | \name{concentration_profile} 4 | \alias{concentration_profile} 5 | \alias{concentrationProfile} 6 | \title{Generic method for concentration profiles} 7 | \usage{ 8 | concentration_profile(object, session = NULL, what = NULL, ...) 9 | 10 | concentrationProfile(object, session = NULL, what = NULL, ...) 11 | } 12 | \arguments{ 13 | \item{object}{An object of class \code{\link{trackeRdata}} or \code{\link{distrProfile}}.} 14 | 15 | \item{session}{A numeric vector of the sessions to be used, 16 | defaults to all sessions.} 17 | 18 | \item{what}{The variables for which the distribution profiles 19 | should be generated. Defaults to all variables in \code{object} 20 | (\code{what = NULL}).} 21 | 22 | \item{...}{Currently not used.} 23 | } 24 | \description{ 25 | Generic method for concentration profiles 26 | } 27 | \examples{ 28 | \dontrun{ 29 | ## Compute conecntration profiles from distribution profiles 30 | data('run', package = 'trackeR') 31 | dProfile <- distributionProfile(run, what = 'speed', grid = seq(0, 12.5, by = 0.05)) 32 | cProfile <- concentrationProfile(dProfile) 33 | plot(cProfile, smooth = FALSE) 34 | plot(cProfile) 35 | 36 | ## And now directly from the 'trackeRdata' object, which is a 37 | ## considerably faster if all that is needed are the concentration 38 | ## profiles 39 | cProfile <- concentrationProfile(runs, what = 'speed', 40 | limits = list(speed = c(0, 12.5))) 41 | plot(cProfile, smooth = FALSE) 42 | ridges(cProfile) 43 | plot(cProfile, smooth = TRUE) 44 | } 45 | } 46 | \seealso{ 47 | concentration_profile.distrProfile concentration_profile.trackeRdata 48 | } 49 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master, develop] 6 | pull_request: 7 | 8 | name: R-CMD-check.yaml 9 | 10 | permissions: read-all 11 | 12 | jobs: 13 | R-CMD-check: 14 | runs-on: ${{ matrix.config.os }} 15 | 16 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 17 | 18 | strategy: 19 | fail-fast: false 20 | matrix: 21 | config: 22 | - {os: macos-latest, r: 'release'} 23 | - {os: windows-latest, r: 'release'} 24 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 25 | - {os: ubuntu-latest, r: 'release'} 26 | - {os: ubuntu-latest, r: 'oldrel-1'} 27 | 28 | env: 29 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 30 | R_KEEP_PKG_SOURCE: yes 31 | 32 | steps: 33 | - uses: actions/checkout@v4 34 | 35 | - uses: r-lib/actions/setup-pandoc@v2 36 | 37 | - uses: r-lib/actions/setup-tinytex@v2 38 | env: 39 | TINYTEX_INSTALLER: TinyTeX-2 40 | 41 | - uses: r-lib/actions/setup-r@v2 42 | with: 43 | r-version: ${{ matrix.config.r }} 44 | http-user-agent: ${{ matrix.config.http-user-agent }} 45 | use-public-rspm: true 46 | 47 | - uses: r-lib/actions/setup-r-dependencies@v2 48 | with: 49 | extra-packages: any::rcmdcheck 50 | needs: check 51 | 52 | - uses: r-lib/actions/check-r-package@v2 53 | with: 54 | upload-snapshots: true 55 | build_args: 'c("--no-manual", "--compact-vignettes=gs+qpdf")' 56 | -------------------------------------------------------------------------------- /tests/testthat/test-summary.R: -------------------------------------------------------------------------------- 1 | context("implementation [summary, change_units, timeline]") 2 | 3 | 4 | data("runs", package = "trackeR") 5 | 6 | tol <- .Machine$double.eps 7 | 8 | 9 | test_that("summary method for trackeRdata objects [class, methods, output]", { 10 | summ <- summary(runs, unit_reference_sport = "cycling") 11 | expect_true(inherits(summ, "trackeRdataSummary")) 12 | expect_equal(nsessions(summ), 27, tolerance = tol) 13 | expect_true(as.numeric(sum(session_duration(summ))) > 1000) 14 | expect_equal(dim(get_units(summ)), c(30, 3), tolerance = tol) 15 | expect_equal(attr(summ, "moving_threshold"), c(cycling = 2, running = 1, swimming = 0.5), tolerance = tol) 16 | expect_equal(attr(summ, "unit_reference_sport"), "cycling", tolerance = tol) 17 | expect_output(print(summ), "Session|Distance|Duration|Moving time|Average speed|Average speed moving|Work to rest ratio|Moving thresholds") 18 | }) 19 | 20 | test_that("summary method for trackeRdata objects [change_units]", { 21 | summ0 <- summary(runs, unit_reference_sport = "cycling") 22 | summ1 <- summary(change_units(runs, c("speed", "distance"), c("mi_per_h", "mi"), c("cycling", "cycling")), 23 | unit_reference_sport = "cycling") 24 | summ2 <- change_units(summ0, c("speed", "distance"), c("mi_per_h", "mi")) 25 | 26 | expect_equal(summ1, summ2, tolerance = tol) 27 | for (j in seq_along(summ0)) { 28 | expect_equal(m2mi(as.data.frame(summ0)[, "distance"]), as.data.frame(summ1)[, "distance"]) 29 | expect_equal(m_per_s2mi_per_h(as.data.frame(summ0)[, "avgSpeed"]), as.data.frame(summ1)[, "avgSpeed"]) 30 | expect_equal(m_per_s2mi_per_h(as.data.frame(summ0)[, "avgSpeedMoving"]), as.data.frame(summ1)[, "avgSpeedMoving"]) 31 | } 32 | }) 33 | -------------------------------------------------------------------------------- /man/smoother_control.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_smoother.R, R/zzz_aliases.R 3 | \name{smoother_control.trackeRdata} 4 | \alias{smoother_control.trackeRdata} 5 | \alias{smootherControl.trackeRdata} 6 | \title{Auxiliary function for \code{\link{smoother.trackeRdata}}. Typically used to construct 7 | a control argument for \code{\link{smoother.trackeRdata}}.} 8 | \usage{ 9 | smoother_control.trackeRdata( 10 | fun = "mean", 11 | width = 10, 12 | parallel = FALSE, 13 | what = c("speed", "heart_rate"), 14 | nsessions = NA, 15 | ... 16 | ) 17 | 18 | smootherControl.trackeRdata( 19 | fun = "mean", 20 | width = 10, 21 | parallel = FALSE, 22 | what = c("speed", "heart_rate"), 23 | nsessions = NA, 24 | ... 25 | ) 26 | } 27 | \arguments{ 28 | \item{fun}{The name of the function to be matched and used to 29 | aggregate/smooth the data.} 30 | 31 | \item{width}{The width of the window in which the raw observations 32 | get aggregated via function \code{fun}.} 33 | 34 | \item{parallel}{Logical. Should computation be carried out in 35 | parallel? If \code{TRUE} computation is performed in parallel 36 | using the backend provided to \pkg{foreach}. Default is 37 | \code{FALSE}.} 38 | 39 | \item{what}{Vector of the names of the variables which should be 40 | smoothed.} 41 | 42 | \item{nsessions}{Vector containing the number of session. Default 43 | corresponds to all sessions belonging to the same group. Used 44 | only internally.} 45 | 46 | \item{...}{Currently not used.} 47 | } 48 | \description{ 49 | Auxiliary function for \code{\link{smoother.trackeRdata}}. Typically used to construct 50 | a control argument for \code{\link{smoother.trackeRdata}}. 51 | } 52 | \seealso{ 53 | \code{\link{smoother.trackeRdata}} 54 | } 55 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | README.md 2 | README.Rmd 3 | README_files/ 4 | README.html 5 | ^\.travis\.yml$ 6 | ^codecov\.yml$ 7 | ^coveralls\.yml$ 8 | vignettes/jss.bst 9 | vignettes/jss.cls 10 | .Rhistory 11 | .DS_Store 12 | 13 | GBR* 14 | 15 | data-raw/ 16 | ^notes\.org$ 17 | ^classifier\.R$ 18 | 19 | inst/extdata/tcx/2013-06-02-072348.TCX.gz 20 | inst/extdata/tcx/2013-06-03-184846.TCX.gz 21 | inst/extdata/tcx/2013-06-04-174137.TCX.gz 22 | inst/extdata/tcx/2013-06-05-062419.TCX.gz 23 | inst/extdata/tcx/2013-06-06-124422.TCX.gz 24 | inst/extdata/tcx/2013-06-09-165756.TCX.gz 25 | inst/extdata/tcx/2013-06-11-181035.TCX.gz 26 | inst/extdata/tcx/2013-06-12-182257.TCX.gz 27 | inst/extdata/tcx/2013-06-14-095723.TCX.gz 28 | inst/extdata/tcx/2013-06-14-100911.TCX.gz 29 | inst/extdata/tcx/2013-06-14-105252.TCX.gz 30 | inst/extdata/tcx/2013-06-15-084005.TCX.gz 31 | inst/extdata/tcx/2013-06-15-090638.TCX.gz 32 | inst/extdata/tcx/2013-06-16-124414.TCX.gz 33 | inst/extdata/tcx/2013-06-17-182443.TCX.gz 34 | inst/extdata/tcx/2013-06-18-063609.TCX.gz 35 | inst/extdata/tcx/2013-06-19-174449.TCX.gz 36 | inst/extdata/tcx/2013-06-19-175630.TCX.gz 37 | inst/extdata/tcx/2013-06-19-183041.TCX.gz 38 | inst/extdata/tcx/2013-06-20-180628.TCX.gz 39 | inst/extdata/tcx/2013-06-21-174510.TCX.gz 40 | inst/extdata/tcx/2013-06-22-150811.TCX.gz 41 | inst/extdata/tcx/2013-06-23-080959.TCX.gz 42 | inst/extdata/tcx/2013-06-23-100845.TCX.gz 43 | inst/extdata/tcx/2013-06-24-151957.TCX.gz 44 | inst/extdata/tcx/2013-06-25-174514.TCX.gz 45 | inst/extdata/tcx/2013-06-26-181438.TCX.gz 46 | inst/extdata/tcx/2013-06-28-062238.TCX.gz 47 | inst/extdata/tcx/2013-06-29-064742.TCX.gz 48 | inst/extdata/tcx/2013-06-30-070511.TCX.gz 49 | inst/extdata/tcx/2013-06-30-084200.TCX.gz 50 | 51 | inst/scratch/ 52 | 53 | vignettes/TourDetrackeR_files/ 54 | 55 | tests/ 56 | ^CRAN-SUBMISSION$ 57 | ^\.github$ 58 | -------------------------------------------------------------------------------- /man/GC2trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata.R 3 | \name{GC2trackeRdata} 4 | \alias{GC2trackeRdata} 5 | \title{Coercion function for use in Golden Cheetah} 6 | \usage{ 7 | GC2trackeRdata( 8 | gc, 9 | cycling = TRUE, 10 | correct_distances = FALSE, 11 | country = NULL, 12 | mask = TRUE, 13 | from_distances = FALSE, 14 | lgap = 30, 15 | lskip = 5, 16 | m = 11, 17 | silent = FALSE 18 | ) 19 | } 20 | \arguments{ 21 | \item{gc}{Output of \code{GC.activity}.} 22 | 23 | \item{cycling}{Logical. Does the data stem from cycling?} 24 | 25 | \item{correct_distances}{Logical. Should the distances be corrected 26 | for elevation? Default is \code{FALSE}.} 27 | 28 | \item{country}{ISO3 country code for downloading altitude data. If 29 | \code{NULL}, country is derived from longitude and latitude} 30 | 31 | \item{mask}{Logical. Passed on to 32 | \code{\link[raster]{getData}}. Should only the altitudes for 33 | the specified \code{country} be extracted (\code{TRUE}) or also 34 | those for the neighbouring countries (\code{FALSE})?} 35 | 36 | \item{from_distances}{Logical. Should the speeds be calculated from the distance recordings 37 | instead of taken from the speed recordings directly?} 38 | 39 | \item{lgap}{Time in seconds corresponding to the minimal sampling rate.} 40 | 41 | \item{lskip}{Time in seconds between the last observation before a small break 42 | and the first imputed speed or the last imputed speed and the first 43 | observation after a small break.} 44 | 45 | \item{m}{Number of imputed observations in each small break.} 46 | 47 | \item{silent}{Logical. Should warnings be generated if any of the 48 | sanity checks on the data are triggered?} 49 | } 50 | \description{ 51 | Coercion function for use in Golden Cheetah 52 | } 53 | \seealso{ 54 | \code{\link{trackeRdata}} 55 | } 56 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: trackeR 2 | Version: 1.6.1 3 | Title: Infrastructure for Running, Cycling and Swimming Data from GPS-Enabled Tracking Devices 4 | Authors@R: c(person(given = "Ioannis", family = "Kosmidis", 5 | role = c("aut", "cre"), email = "ioannis.kosmidis@warwick.ac.uk", 6 | comment = c(ORCID = "0000-0003-1556-0302")), 7 | person(given = "Hannah", family = "Frick", 8 | role = "aut", email = "hannah.frick@gmail.com", 9 | comment = c(ORCID = "0000-0002-6049-5258")), 10 | person(given = "Robin", family = "Hornak", 11 | role = "aut", email = "robinhornak@gmail.com")) 12 | 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) , 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. 13 | Depends: 14 | R (>= 3.1.0), 15 | zoo 16 | Imports: 17 | ggplot2, 18 | ggridges, 19 | xml2, 20 | RSQLite, 21 | jsonlite, 22 | raster, 23 | scam, 24 | foreach, 25 | fda, 26 | sp, 27 | leaflet, 28 | ggmap, 29 | patchwork 30 | Suggests: 31 | spelling, 32 | testthat, 33 | knitr, 34 | rmarkdown, 35 | covr 36 | VignetteBuilder: knitr 37 | License: GPL-3 38 | URL: https://github.com/trackerproject/trackeR 39 | BugReports: https://github.com/trackerproject/trackeR/issues 40 | RoxygenNote: 7.3.2 41 | Encoding: UTF-8 42 | LazyData: true 43 | Language: en-GB 44 | -------------------------------------------------------------------------------- /man/zones.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_zones.R 3 | \name{zones} 4 | \alias{zones} 5 | \title{Time spent in training zones.} 6 | \usage{ 7 | zones( 8 | object, 9 | session = NULL, 10 | what = c("speed"), 11 | breaks = NULL, 12 | parallel = FALSE, 13 | n_zones = 9, 14 | unit_reference_sport = NULL, 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{object}{An object of class \code{\link{trackeRdata}}.} 20 | 21 | \item{session}{A numeric vector of the sessions to be plotted, 22 | defaults to all sessions.} 23 | 24 | \item{what}{A vector of variable names.} 25 | 26 | \item{breaks}{A list of breakpoints between zones, corresponding to 27 | the variables in \code{what}.} 28 | 29 | \item{parallel}{Logical. Should computation be carried out in 30 | parallel? If \code{TRUE} computation is performed in parallel 31 | using the backend provided to \pkg{foreach}. Default is 32 | \code{FALSE}.} 33 | 34 | \item{n_zones}{numeric that sets the number of zones for data to be 35 | split into. Default is \code{9}.} 36 | 37 | \item{unit_reference_sport}{The sport to inherit units from 38 | (default is taken to be the most frequent sport in 39 | \code{object}).} 40 | 41 | \item{...}{Currently not used.} 42 | } 43 | \value{ 44 | An object of class \code{trackeRdataZones}. 45 | } 46 | \description{ 47 | Time spent in training zones. 48 | } 49 | \examples{ 50 | data('run', package = 'trackeR') 51 | runZones <- zones(run, what = 'speed', breaks = list(speed = c(0, 2:6, 12.5))) 52 | ## if breaks is a named list, argument 'what' can be left unspecified 53 | runZones <- zones(run, breaks = list(speed = c(0, 2:6, 12.5))) 54 | ## if only a single variable is to be evaluated, 'breaks' can also be a vector 55 | runZones <- zones(run, what = 'speed', breaks = c(0, 2:6, 12.5)) 56 | plot(runZones) 57 | } 58 | \seealso{ 59 | \code{\link{plot.trackeRdataZones}} 60 | } 61 | -------------------------------------------------------------------------------- /man/smoother.distrProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R 3 | \name{smoother.distrProfile} 4 | \alias{smoother.distrProfile} 5 | \title{Smoother for distribution profiles.} 6 | \usage{ 7 | \method{smoother}{distrProfile}(object, session = NULL, what = NULL, control = list(...), ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{distrProfile} as returned by 11 | \code{\link{distribution_profile}}.} 12 | 13 | \item{session}{A numeric vector of the sessions to be selected and 14 | smoothed. Defaults to all sessions.} 15 | 16 | \item{what}{A character version of the variables to be selected and 17 | smoothed. Defaults to all variables in \code{object} 18 | (\code{what = NULL}).} 19 | 20 | \item{control}{A list of parameters for controlling the smoothing 21 | process. This is passed to 22 | \code{\link{smoother_control.distrProfile}}.} 23 | 24 | \item{...}{Arguments to be used to form the default \code{control} 25 | argument if it is not supplied directly.} 26 | } 27 | \description{ 28 | The distribution profiles are smoothed using a shape constrained 29 | additive model with Poisson responses to ensure that the smoothed 30 | distribution profile is positive and monotone decreasing. 31 | } 32 | \references{ 33 | Kosmidis, I., and Passfield, L. (2015). Linking the Performance of 34 | Endurance Runners to Training and Physiological Effects via 35 | Multi-Resolution Elastic Net. \emph{ArXiv e-print} 36 | arXiv:1506.01388. 37 | 38 | Pya, N. and Wood S. (2015). Shape Constrained Additive 39 | Models. Statistics and Computing, 25(3), 543--559. Frick, H., 40 | 41 | Kosmidis, I. (2017). trackeR: Infrastructure for Running and 42 | Cycling Data from GPS-Enabled Tracking Devices in R. \emph{Journal 43 | of Statistical Software}, \bold{82}(7), 44 | 1--29. doi:10.18637/jss.v082.i07 45 | } 46 | \seealso{ 47 | \code{\link{smoother_control.distrProfile}} 48 | } 49 | -------------------------------------------------------------------------------- /man/generate_units.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/constants.R, R/zzz_aliases.R 3 | \name{generate_units} 4 | \alias{generate_units} 5 | \alias{generateBaseUnits} 6 | \title{Generate and set base units.} 7 | \usage{ 8 | generate_units(variable, unit, sport, ...) 9 | 10 | generateBaseUnits(variable, unit, sport, ...) 11 | } 12 | \arguments{ 13 | \item{variable}{A vector of variables with user-specified units.} 14 | 15 | \item{unit}{A vector with the user-specified units, corresponding 16 | to variable (see details).} 17 | 18 | \item{sport}{A vector of sports (amongst \code{'cycling'}, 19 | \code{'running'}, \code{'swimming'}) with each element 20 | corresponding to \code{variable} and \code{unit}.} 21 | 22 | \item{...}{Currently not used.} 23 | } 24 | \description{ 25 | Generate and set base units. 26 | } 27 | \details{ 28 | The available units are 29 | \itemize{ 30 | 31 | \item variables \code{latitude} and \code{longitude} with unit 32 | \code{degree} (default) 33 | 34 | \item variables \code{altitude}, \code{distance} with unit \code{m} 35 | (default), \code{km}, \code{mi} or \code{ft} 36 | 37 | \item variable \code{heart_rate} with unit \code{bpm} (default) 38 | 39 | \item variable \code{speed} with unit \code{m_per_s} (default), 40 | \code{km_per_h}, \code{ft_per_min}, \code{ft_per_s} or 41 | \code{mi_per_h} 42 | 43 | \item variable \code{cadence_running} with unit 44 | \code{steps_per_min} (default; running only) 45 | 46 | \item variable \code{cadence_cycling} with unit \code{rev_per_min} 47 | (default; cycling only) 48 | 49 | \item variable \code{power} with unit \code{W} (Watt; default) or 50 | \code{kW} (cycling only) 51 | 52 | \item variable \code{temperature} with unit \code{C} (Celsius; 53 | default) or \code{F} 54 | } 55 | 56 | Note that \code{generate_units} checks if the supplied combinations 57 | of \code{variable} and \code{sport} are valid. 58 | \code{generate_units} will not check if any of the supplied units 59 | are correct for the corresponding combination of \code{variable} 60 | and \code{sport}. 61 | } 62 | -------------------------------------------------------------------------------- /R/zzz_aliases.R: -------------------------------------------------------------------------------- 1 | #' @rdname get_units 2 | #' @export 3 | getUnits <- get_units 4 | 5 | #' @rdname change_units 6 | #' @export 7 | changeUnits <- change_units 8 | 9 | #' @rdname get_resting_periods 10 | #' @export 11 | restingPeriods <- get_resting_periods 12 | 13 | #' @rdname impute_speeds 14 | #' @export 15 | imputeSpeeds <- impute_speeds 16 | 17 | #' @rdname read_container 18 | #' @export 19 | readContainer <- read_container 20 | 21 | #' @rdname read_directory 22 | #' @export 23 | readDirectory <- read_directory 24 | 25 | generateVariableNames <- generate_variable_names 26 | 27 | #' @rdname generate_units 28 | #' @export 29 | generateBaseUnits <- generate_units 30 | 31 | #' @rdname generate_thresholds 32 | #' @export 33 | generateDefaultThresholds <- generate_thresholds 34 | 35 | #' @rdname get_operations 36 | #' @export 37 | getOperations <- get_operations 38 | 39 | #' @rdname smoother_control.trackeRdata 40 | #' @export 41 | smootherControl.trackeRdata <- smoother_control.trackeRdata 42 | 43 | #' @rdname plot_route 44 | #' @export 45 | plotRoute <- plot_route 46 | 47 | #' @rdname leaflet_route 48 | #' @export 49 | leafletRoute <- leaflet_route 50 | 51 | #' @rdname concentration_profile 52 | #' @export 53 | concentrationProfile <- concentration_profile 54 | 55 | 56 | #' @rdname distribution_profile 57 | #' @export 58 | distributionProfile <- distribution_profile 59 | 60 | #' @rdname decreasing_smoother 61 | #' @export 62 | decreasingSmoother <- decreasing_smoother 63 | 64 | #' @rdname smoother_control.distrProfile 65 | #' @export 66 | smootherControl.distrProfile <- smoother_control.distrProfile 67 | 68 | #' @rdname fortify.trackeRdata 69 | #' @export 70 | fortify_trackeRdata <- fortify.trackeRdata 71 | 72 | #' @rdname fortify.trackeRdataSummary 73 | #' @export 74 | fortify_trackeRdataSummary <- fortify.trackeRdataSummary 75 | 76 | #' @rdname fortify.conProfile 77 | #' @export 78 | fortify_conProfile <- fortify.conProfile 79 | 80 | #' @rdname fortify.distrProfile 81 | #' @export 82 | fortify_distrProfile <- fortify.distrProfile 83 | 84 | #' @rdname fortify.trackeRWprime 85 | #' @export 86 | fortify_trackeRWprime <- fortify.trackeRWprime 87 | 88 | 89 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | inst/doc 2 | 3 | ### macOS ### 4 | # General 5 | .DS_Store 6 | .AppleDouble 7 | .LSOverride 8 | 9 | # Icon must end with two \r 10 | Icon 11 | 12 | # Thumbnails 13 | ._* 14 | 15 | # Files that might appear in the root of a volume 16 | .DocumentRevisions-V100 17 | .fseventsd 18 | .Spotlight-V100 19 | .TemporaryItems 20 | .Trashes 21 | .VolumeIcon.icns 22 | .com.apple.timemachine.donotpresent 23 | 24 | # Directories potentially created on remote AFP share 25 | .AppleDB 26 | .AppleDesktop 27 | Network Trash Folder 28 | Temporary Items 29 | .apdisk 30 | 31 | ### R ### 32 | # History files 33 | .Rhistory 34 | .Rapp.history 35 | 36 | # Session Data files 37 | .RData 38 | 39 | # Example code in package build process 40 | *-Ex.R 41 | 42 | # Output files from R CMD build 43 | /*.tar.gz 44 | 45 | # Output files from R CMD check 46 | /*.Rcheck/ 47 | 48 | # RStudio files 49 | .Rproj.user/ 50 | 51 | # produced vignettes 52 | vignettes/*.html 53 | vignettes/*.pdf 54 | 55 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 56 | .httr-oauth 57 | 58 | # knitr and R markdown default cache directories 59 | /*_cache/ 60 | /cache/ 61 | 62 | # Temporary files created by R markdown 63 | *.utf8.md 64 | *.knit.md 65 | 66 | ### R.Bookdown Stack ### 67 | # R package: bookdown caching files 68 | 69 | 70 | ### Emacs ### 71 | # -*- mode: gitignore; -*- 72 | *~ 73 | \#*\# 74 | /.emacs.desktop 75 | /.emacs.desktop.lock 76 | *.elc 77 | auto-save-list 78 | tramp 79 | .\#* 80 | 81 | # Org-mode 82 | .org-id-locations 83 | *_archive 84 | 85 | # flymake-mode 86 | *_flymake.* 87 | 88 | # eshell files 89 | /eshell/history 90 | /eshell/lastdir 91 | 92 | # elpa packages 93 | /elpa/ 94 | 95 | # reftex files 96 | *.rel 97 | 98 | # AUCTeX auto folder 99 | /auto/ 100 | 101 | # cask packages 102 | .cask/ 103 | dist/ 104 | 105 | # Flycheck 106 | flycheck_*.el 107 | 108 | # server auth directory 109 | /server/ 110 | 111 | # projectiles files 112 | .projectile 113 | 114 | # directory configuration 115 | .dir-locals.el 116 | 117 | # network security 118 | /network-security.data 119 | 120 | ### Project related files ### 121 | GBR_msk_alt* -------------------------------------------------------------------------------- /tests/testthat/test-threshold.R: -------------------------------------------------------------------------------- 1 | context("implementation [thresholding of trackeRdata objects]") 2 | 3 | 4 | data("runs", package = "trackeR") 5 | 6 | test_that("thresholds are generated correctly [defaults and user-supplied bounds]", { 7 | expect_error(generate_thresholds("speed")) 8 | expect_error(generate_thresholds(lower = c(0, 2))) 9 | g0 <- generate_thresholds() 10 | g <- generate_thresholds(variable = c("speed", "altitude"), 11 | lower = c(0, 0), 12 | upper = c(2, 2), 13 | sport = c("swimming", "cycling")) 14 | inds1 <- g$sport == "cycling" & g$variable == "altitude" 15 | inds2 <- g$sport == "swimming" & g$variable == "speed" 16 | expect_equal(g[inds1, "lower"], 0) 17 | expect_equal(g[inds1, "upper"], 2) 18 | expect_equal(g[inds2, "lower"], 0) 19 | expect_equal(g[inds2, "upper"], 2) 20 | expect_equal(g0[!(inds1 | inds2), ], g[!(inds1 | inds2), ]) 21 | }) 22 | 23 | test_that("thresholds are applied correctly [speed, altitude]", { 24 | runs_th <- threshold(runs, variable = "speed", lower = 1, upper = 3, sport = "running") 25 | expect_true(all(sapply(runs_th, function(x) all(x[, "speed"] >= 1 & x[, "speed"] <= 3, na.rm = TRUE)))) 26 | runs_th <- threshold(runs, variable = c("speed", "altitude"), lower = c(1, 10), upper = c(3, 20), sport = c("running", "running")) 27 | expect_true(all(sapply(runs_th, function(x) all(x[, "speed"] >= 1 & x[, "speed"] <= 3, na.rm = TRUE)))) 28 | expect_true(all(sapply(runs_th, function(x) all(x[, "altitude"] >= 10 & x[, "altitude"] <= 20, na.rm = TRUE)))) 29 | }) 30 | 31 | test_that("change_units works with threshods", { 32 | runs_th <- threshold(runs, variable = "speed", lower = 1, upper = 3, sport = "running") 33 | r <- change_units(runs_th, variable = "speed", unit = "km_per_h", sport = "running") 34 | for (j in seq_along(r)) { 35 | expect_equal(runs_th[[j]][, "speed"]/1000 * 60 * 60, r[[j]][, "speed"]) 36 | } 37 | }) 38 | 39 | 40 | test_that("threshold works with all variables", { 41 | th <- generate_thresholds() 42 | expect(nsessions(threshold(runs, th$variable, th$lower, th$upper, th$sport)), nsessions(runs)) 43 | }) 44 | 45 | 46 | -------------------------------------------------------------------------------- /man/impute_speeds.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cleaning.R, R/zzz_aliases.R 3 | \name{impute_speeds} 4 | \alias{impute_speeds} 5 | \alias{imputeSpeeds} 6 | \title{Impute speeds} 7 | \usage{ 8 | impute_speeds( 9 | session_data, 10 | from_distances = TRUE, 11 | lgap = 30, 12 | lskip = 5, 13 | m = 11, 14 | sport = "cycling", 15 | units = NULL 16 | ) 17 | 18 | imputeSpeeds( 19 | session_data, 20 | from_distances = TRUE, 21 | lgap = 30, 22 | lskip = 5, 23 | m = 11, 24 | sport = "cycling", 25 | units = NULL 26 | ) 27 | } 28 | \arguments{ 29 | \item{session_data}{A multivariate \code{\link[zoo]{zoo}} object with 30 | observations of either distance or speed (named Distance or Speed, 31 | respectively).} 32 | 33 | \item{from_distances}{Logical. Should the speeds be calculated from the distance recordings 34 | instead of taken from the speed recordings directly?} 35 | 36 | \item{lgap}{Time in seconds corresponding to the minimal sampling rate.} 37 | 38 | \item{lskip}{Time in seconds between the last observation before a small break 39 | and the first imputed speed or the last imputed speed and the first 40 | observation after a small break.} 41 | 42 | \item{m}{Number of imputed observations in each small break.} 43 | 44 | \item{sport}{What sport does \code{sessions_data} contain data of? Either 45 | \code{'cycling'} (default), \code{'running'}, \code{'swimming'}.} 46 | 47 | \item{units}{Units of measurement.} 48 | } 49 | \value{ 50 | A multivariate \code{\link[zoo]{zoo}} object with imputed observations: 51 | 0 for speed, last known position for latitude, longitude and altitude, 52 | NA for all other variables. Distances are calculated based on speeds after imputation. 53 | } 54 | \description{ 55 | Impute speeds of 0 during small breaks within a session. 56 | } 57 | \references{ 58 | Kosmidis, I., and Passfield, L. (2015). Linking the Performance of 59 | Endurance Runners to Training and Physiological Effects via 60 | Multi-Resolution Elastic Net. \emph{ArXiv e-print} 61 | arXiv:1506.01388. 62 | 63 | Frick, H., Kosmidis, I. (2017). trackeR: Infrastructure for Running 64 | and Cycling Data from GPS-Enabled Tracking Devices in 65 | R. \emph{Journal of Statistical Software}, \bold{82}(7), 66 | 1--29. doi:10.18637/jss.v082.i07 67 | } 68 | -------------------------------------------------------------------------------- /tests/testthat/test-trackeRdata.R: -------------------------------------------------------------------------------- 1 | context("implementation [trackeRdata, read_container]") 2 | 3 | tcxfile <- system.file("extdata/tcx/", "2013-06-30-070511.TCX.gz", package = "trackeR") 4 | gpxfile <- system.file("extdata/gpx/", "20170709-151453-Ride.gpx.gz", package = "trackeR") 5 | gpxfile_swim <- system.file("extdata/gpx/", "20170714-143644-Swim.gpx.gz", package = "trackeR") 6 | 7 | tol <- .Machine$double.eps 8 | 9 | tcx1 <- read_container(tcxfile, silent = TRUE) 10 | tcx2 <- read_container(tcxfile, session_threshold = 0.5/60, silent = TRUE) 11 | gpx4 <- read_container(gpxfile, type = "gpx", session_threshold = 0.5/60, silent = FALSE) 12 | gpx1 <- read_container(gpxfile_swim, type = "gpx", session_threshold = 2, silent = FALSE) 13 | 14 | test_that("class of object from read_container is trackeRdata", { 15 | ## read_container 16 | expect_is(tcx1, "trackeRdata") 17 | expect_is(tcx2, "trackeRdata") 18 | expect_is(gpx4, "trackeRdata") 19 | }) 20 | 21 | test_that("trackeRdata extractor methods work [nsessions]", { 22 | expect_equal(nsessions(tcx1), 1, tolerance = tol) 23 | expect_equal(nsessions(tcx2), 2, tolerance = tol) 24 | expect_equal(nsessions(gpx4), 4, tolerance = tol) 25 | }) 26 | 27 | test_that("trackeRdata extractor methods work [sport]", { 28 | expect_equal(get_sport(tcx1), "running") 29 | expect_equal(get_sport(tcx2), rep("running", 2)) 30 | expect_equal(get_sport(gpx4), rep("cycling", 4)) 31 | expect_equal(get_sport(gpx1), "swimming") 32 | }) 33 | 34 | test_that("trackeRdata extractor methods work [session_duration, session_times]", { 35 | expect_equal(as.numeric(session_duration(tcx1)), 5642/60/60, tolerance = tol) 36 | expect_equal(as.numeric(session_duration(tcx2)), c(1640, 3970)/60/60, tolerance = tol) 37 | expect_equal(as.numeric(session_duration(gpx1)), 2095/60/60, tolerance = tol) 38 | expect_is(session_times(gpx4), "data.frame") 39 | expect_equal(nrow(session_times(gpx4)), 4) 40 | expect_equal(names(session_times(gpx4)), c("sessionStart", "sessionEnd")) 41 | }) 42 | 43 | test_that("c.trackeRdata works as expected [c-ing]", { 44 | 45 | s_12 <- c(tcx1, tcx2) 46 | expect_true(identical(s_12[1], tcx1) ) 47 | 48 | s_all <- c(s_12, gpx4, gpx1) 49 | expect_true(identical(s_all[1:3], s_12)) 50 | 51 | expect_true(identical(s_all[4:7], gpx4)) 52 | 53 | 54 | 55 | }) 56 | -------------------------------------------------------------------------------- /man/plot_route.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_plot.R, R/zzz_aliases.R 3 | \name{plot_route} 4 | \alias{plot_route} 5 | \alias{plotRoute} 6 | \title{Plot routes for training sessions} 7 | \usage{ 8 | plot_route( 9 | x, 10 | session = 1, 11 | zoom = NULL, 12 | speed = TRUE, 13 | threshold = TRUE, 14 | mfrow = NULL, 15 | maptype = "stamen_terrain", 16 | messaging = FALSE, 17 | ... 18 | ) 19 | 20 | plotRoute( 21 | x, 22 | session = 1, 23 | zoom = NULL, 24 | speed = TRUE, 25 | threshold = TRUE, 26 | mfrow = NULL, 27 | maptype = "stamen_terrain", 28 | messaging = FALSE, 29 | ... 30 | ) 31 | } 32 | \arguments{ 33 | \item{x}{A object of class \code{\link{trackeRdata}}.} 34 | 35 | \item{session}{A numeric vector of the sessions to be plotted. Defaults 36 | to the first session, all sessions can be plotted by \code{session = NULL}.} 37 | 38 | \item{zoom}{The zoom level for the background map as passed on to 39 | \code{\link[ggmap]{get_stadiamap}} (2 corresponds roughly to continent 40 | level and 20 to building level).} 41 | 42 | \item{speed}{Logical. Should the trace be coloured according to speed?} 43 | 44 | \item{threshold}{Logical. Should thresholds be applied?} 45 | 46 | \item{mfrow}{A vector of 2 elements, number of rows and number of columns, 47 | specifying the layout for multiple sessions.} 48 | 49 | \item{maptype}{Passed to \code{\link[ggmap]{get_stadiamap}}. Default is \code{"stamen_terrain"}.} 50 | 51 | \item{messaging}{Passed to \code{\link[ggmap]{get_stadiamap}}. Default is \code{FALSE}.} 52 | 53 | \item{...}{Additional arguments passed on to \code{\link{threshold}} and 54 | \code{\link[ggmap]{get_stadiamap}}.} 55 | } 56 | \description{ 57 | Plot the route ran/cycled during training onto a background map. 58 | Internet connection is required to download the background map. 59 | } 60 | \details{ 61 | \code{plot_route()} requires a a Stadia Maps API key. See \code{\link[ggmap]{register_stadiamaps}} for details. 62 | } 63 | \examples{ 64 | \dontrun{ 65 | data('runs', package = 'trackeR') 66 | plot_route(runs, session = 4, zoom = 13) 67 | plot_route(runs, session = 4, zoom = 13, maptype = "outdoors") 68 | ## multiple sessions 69 | plot_route(runs, session = c(1:4, 8:11)) 70 | ## different zoom level per panel 71 | plot_route(runs, session = 6:7, zoom = c(13, 14)) 72 | } 73 | } 74 | \seealso{ 75 | \code{\link[ggmap]{get_stadiamap}}, \code{\link[ggmap]{ggmap}} 76 | } 77 | -------------------------------------------------------------------------------- /man/threshold.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/thresholds.R, R/trackeR.R 3 | \name{threshold.trackeRdata} 4 | \alias{threshold.trackeRdata} 5 | \alias{threshold} 6 | \title{Thresholding for variables in \code{trackeRdata} objects} 7 | \usage{ 8 | \method{threshold}{trackeRdata}(object, variable, lower, upper, sport, trace = FALSE, ...) 9 | 10 | threshold(object, ...) 11 | } 12 | \arguments{ 13 | \item{object}{An object of class \code{\link{trackeRdata}}.} 14 | 15 | \item{variable}{A vector containing the names of the variables to 16 | which thresholding is applied. See Details.} 17 | 18 | \item{lower}{A vector containing the corresponding lower 19 | thresholds. See Details.} 20 | 21 | \item{upper}{A vector containing the corresponding upper 22 | thresholds. See Details.} 23 | 24 | \item{sport}{A vector of sports (amongst \code{'cycling'}, 25 | \code{'running'}, \code{'swimming'}) with each element 26 | corresponding to \code{variable}, \code{lower} and \code{upper}} 27 | 28 | \item{trace}{Should a progress report be printed? Default is \code{FALSE}} 29 | 30 | \item{...}{Currently not used.} 31 | } 32 | \description{ 33 | Thresholding for variables in \code{trackeRdata} objects 34 | } 35 | \details{ 36 | \code{lower} and \code{upper} are always understood as referring to 37 | the units of the \code{object}. 38 | 39 | If the arguments \code{variable}, \code{lower}, and \code{upper} 40 | are all unspecified, the following default thresholds are employed 41 | \itemize{ 42 | \item latitude [-90, 90] degrees 43 | \item longitude [-180, 180] degrees 44 | \item altitude [-500, 9000] m 45 | \item distance [0, Inf] meters 46 | \item cadence_running [0, Inf] steps per min 47 | \item cadence_cycling [0, Inf] revolutions per min 48 | \item speed [0, Inf] meters 49 | \item heart rate [0, 250] bpm 50 | \item power [0, Inf] W 51 | \item pace [0, Inf] min per km 52 | \item duration [0, Inf] seconds 53 | \item temperature [-20, 60] C 54 | } 55 | after they have been transformed to the units of the \code{object} 56 | 57 | The thresholds for speed differ across sports: for running they are 58 | [0, 12.5] meters per second, for cycling [0, 100] meters per second 59 | and for swimming [0, 5] meters per second. 60 | } 61 | \examples{ 62 | \dontrun{ 63 | data('runs', package = 'trackeR') 64 | plot(runs, session = 4, what = 'speed', threshold = FALSE) 65 | runsT <- threshold(runs, variable = 'speed', lower = 0, upper = 12.5, sport = "running") 66 | plot(runsT, session = 4, what = 'speed', threshold = FALSE) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /tests/testthat/test-distribution-profiles.R: -------------------------------------------------------------------------------- 1 | context("implementation [distribution_profile, class, extractors, methods]") 2 | 3 | test_that("disitrbution_profile works as expected [computation and methods]", { 4 | 5 | gpx <- system.file("extdata/gpx/", package = "trackeR") 6 | obj <- read_directory(gpx, silent = TRUE, verbose = FALSE) 7 | 8 | vars <- c(generate_variable_names()$human_names, "pace") 9 | expect_warning(dp <- distribution_profile(obj, what = vars), "no data|time|heart_rate|cadence_cycling") 10 | sm_dp <- smoother(dp, what = c("speed", "pace")) 11 | sc_dp <- scaled(dp, what = c("speed", "pace")) 12 | 13 | expect_true(all(names(dp) %in% vars)) 14 | expect_equal(names(sm_dp), c("speed", "pace")) 15 | expect_equal(names(sm_dp), c("speed", "pace")) 16 | 17 | expect_equal(get_sport(dp), c("running", "cycling", "swimming")) 18 | expect_equal(get_sport(sm_dp), c("running", "cycling", "swimming")) 19 | expect_equal(get_sport(dp), c("running", "cycling", "swimming")) 20 | 21 | expect_equal(get_operations(sm_dp)$smooth, list(k = 30, sp = NULL, parallel = FALSE)) 22 | expect_true(get_operations(sc_dp)$scale) 23 | 24 | expect_equal(attr(dp, "unit_reference_sport"), "cycling") 25 | expect_equal(attr(sm_dp, "unit_reference_sport"), "cycling") 26 | expect_equal(attr(sc_dp, "unit_reference_sport"), "cycling") 27 | 28 | expect_equal(attr(dp, "session_times"), session_times(obj)) 29 | expect_equal(attr(sm_dp, "session_times"), session_times(obj)) 30 | expect_equal(attr(sc_dp, "session_times"), session_times(obj)) 31 | 32 | 33 | expect_equal(unclass(dp$speed[,1]*60), sapply(index(dp$speed), function(th) { 34 | timeAboveThreshold(obj[[1]][, "speed"], threshold = th, ge = FALSE) 35 | }), check.attributes = FALSE) 36 | 37 | ## subset 38 | dps <- get_profile(dp, session = c(1, 3), what = c("speed", "pace")) 39 | 40 | expect_equal(colnames(dps$speed), c("session1", "session3")) 41 | expect_equal(names(dps), c("speed", "pace")) 42 | 43 | att <- attributes(dp) 44 | atts <- attributes(dps) 45 | 46 | expect_equal(att$unit_reference_sport, atts$unit_reference_sport) 47 | expect_equal(att$operations, atts$operations) 48 | expect_equal(att$units, atts$units) 49 | expect_equal(att$sport[-2], atts$sport) 50 | expect_equal(att$session_times[-2, ], atts$session_times) 51 | 52 | expect_equal(class(dp), "distrProfile") 53 | expect_equal(class(sm_dp), "distrProfile") 54 | expect_equal(class(sc_dp), "distrProfile") 55 | expect_equal(class(dps), "distrProfile") 56 | 57 | }) 58 | 59 | -------------------------------------------------------------------------------- /man/summary.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_summary.R 3 | \name{summary.trackeRdata} 4 | \alias{summary.trackeRdata} 5 | \alias{trackeRdataSummary} 6 | \title{Summary of training sessions} 7 | \usage{ 8 | \method{summary}{trackeRdata}( 9 | object, 10 | session = NULL, 11 | moving_threshold = NULL, 12 | unit_reference_sport = NULL, 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{An object of class \code{\link{trackeRdata}}.} 18 | 19 | \item{session}{A numeric vector of the sessions to be summarised, 20 | defaults to all sessions.} 21 | 22 | \item{moving_threshold}{A named vector of 3 speeds above which an 23 | athlete is considered moving, given in the unit of the speed 24 | measurements in \code{object}. If \code{NULL} (default), the 25 | speeds are taken to be \code{c(cycling = 2, running = 1, 26 | swimming = 0.5)}. See Details.} 27 | 28 | \item{unit_reference_sport}{The sport to inherit units from 29 | (default is taken to be the most frequent sport in 30 | \code{object}).} 31 | 32 | \item{...}{Currently not used.} 33 | } 34 | \value{ 35 | An object of class \code{trackeRdataSummary}. 36 | } 37 | \description{ 38 | Summary of training sessions 39 | } 40 | \details{ 41 | The default speed thresholds are 1 m/s for running (3.6 km/h; slow 42 | walking), 2 m/s for cycling (7.2 km/h) for cycling and 0.5 m/s 43 | (1.8km/h) for swimming. For reference, the preferred walking speed 44 | for humans is around 1.4 m/s (Bohannon, 1997). 45 | 46 | The units for the computed summaries match those of the sport 47 | specified by \code{unit_reference_sport}. 48 | 49 | If \code{object} has thresholds then the thresholds that match 50 | those of the sport specified by \code{unit_reference_sport} are 51 | applied to the respective summaries. 52 | } 53 | \examples{ 54 | data('runs', package = 'trackeR') 55 | runSummary <- summary(runs, session = 1:2) 56 | ## print summary 57 | runSummary 58 | print(runSummary, digits = 3) 59 | \dontrun{ 60 | ## change units 61 | change_units(runSummary, variable = 'speed', unit = 'km_per_h') 62 | ## plot summary 63 | runSummaryFull <- summary(runs) 64 | plot(runSummaryFull) 65 | plot(runSummaryFull, group = c('total', 'moving'), 66 | what = c('avgSpeed', 'distance', 'duration', 'avgHeartRate', "total_elevation_gain")) 67 | } 68 | } 69 | \references{ 70 | Bohannon RW (1997). 'Comfortable and Maximum Walking Speed of 71 | Adults Aged 20--79 Years: Reference Values and Determinants.' Age 72 | and Ageing, 26(1), 15--19. doi: 10.1093/ageing/26.1.15. 73 | } 74 | \seealso{ 75 | \code{\link{plot.trackeRdataSummary}} 76 | } 77 | -------------------------------------------------------------------------------- /man/Wexp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Wprime.R 3 | \name{Wexp} 4 | \alias{Wexp} 5 | \title{W' expended.} 6 | \usage{ 7 | Wexp(object, w0, cp, version = c("2015", "2012"), meanRecoveryPower = FALSE) 8 | } 9 | \arguments{ 10 | \item{object}{Univariate \code{\link[zoo]{zoo}} object containing 11 | the time stamped power output or speed values. (Power should be 12 | in Watts, speed in meters per second.)} 13 | 14 | \item{w0}{Initial capacity of W', as calculated based on the 15 | critical power model by Monod and Scherrer (1965).} 16 | 17 | \item{cp}{Critical power/speed, i.e., the power/speed which can be 18 | maintained for longer period of time.} 19 | 20 | \item{version}{How should W' be replenished? Options include 21 | \code{'2015'} and \code{'2012'} for the versions presented in 22 | Skiba et al. (2015) and Skiba et al. (2012), respectively. See 23 | Details.} 24 | 25 | \item{meanRecoveryPower}{Should the mean of all power outputs below 26 | critical power be used as recovery power? See Details.} 27 | } 28 | \description{ 29 | Calculate W' expended, i.e., the work capacity above critical 30 | power/speed which has been depleted and not yet been replenished. 31 | } 32 | \details{ 33 | Skiba et al. (2015) and Skiba et al. (2012) both describe an 34 | exponential decay of \eqn{W'} expended over an interval 35 | \eqn{[t_{i-1}, t_i)} if the power output during this interval is 36 | below critical power: 37 | 38 | \deqn{W_exp (t_i) = W_exp(t_{i-1}) * exp(nu * (t_i - t_{i-1}))} 39 | 40 | However, the factor nu differs: Skiba et al. (2012) describe it as 41 | \eqn{1/\tau} with \eqn{\tau} estimated as 42 | 43 | \deqn{tau = 546 * exp(-0.01 * (CP - P_i)) + 316} 44 | 45 | Skiba et al. (2015) use \eqn{(P_i - CP) / W'_0}. Skiba et 46 | al. (2012) and Skiba et al. (2015) employ a constant recovery power 47 | (calculated as the mean over all power outputs below critical 48 | power). This rationale can be applied by setting the argument 49 | \code{meanRecoveryPower} to \code{TRUE}. Note that this uses 50 | information from all observations with a power output below 51 | critical power, not just those prior to the current time point. 52 | } 53 | \references{ 54 | Monod H, Scherrer J (1965). 'The Work Capacity of a Synergic 55 | Muscular Group.' Ergonomics, 8(3), 329--338. 56 | 57 | Skiba PF, Chidnok W, Vanhatalo A, Jones AM (2012). 'Modeling the 58 | Expenditure and Reconstitution of Work Capacity above Critical 59 | Power.' Medicine & Science in Sports & Exercise, 44(8), 1526--1532. 60 | 61 | Skiba PF, Fulford J, Clarke DC, Vanhatalo A, Jones AM 62 | (2015). 'Intramuscular Determinants of the Ability to Recover 63 | Work Capacity above Critical Power.' European Journal of Applied 64 | Physiology, 115(4), 703--713. 65 | } 66 | -------------------------------------------------------------------------------- /man/readX.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/reading.R 3 | \name{readX} 4 | \alias{readX} 5 | \alias{readTCX} 6 | \alias{readGPX} 7 | \alias{readDB3} 8 | \alias{readJSON} 9 | \title{Read a training file in tcx, gpx, db3 or Golden Cheetah's JSON 10 | format} 11 | \usage{ 12 | readTCX(file, timezone = "", speedunit = "m_per_s", distanceunit = "m", ...) 13 | 14 | readGPX(file, timezone = "", speedunit = "km_per_h", distanceunit = "km", ...) 15 | 16 | readDB3( 17 | file, 18 | timezone = "", 19 | table = "gps_data", 20 | speedunit = "km_per_h", 21 | distanceunit = "km", 22 | ... 23 | ) 24 | 25 | readJSON(file, timezone = "", speedunit = "km_per_h", distanceunit = "km", ...) 26 | } 27 | \arguments{ 28 | \item{file}{The path to a tcx, gpx, json or db3 file. Compressed 29 | versions (gz, bz2, xz, zip) of tcx, gpx, and json files are 30 | directly supported.} 31 | 32 | \item{timezone}{The timezone of the observations as passed on to 33 | \code{\link[base]{as.POSIXct}}. Ignored for JSON files.} 34 | 35 | \item{speedunit}{Character string indicating the measurement unit 36 | of the speeds in the container file to be converted into meters 37 | per second. See Details.} 38 | 39 | \item{distanceunit}{Character string indicating the measurement 40 | unit of the distance in the container file to be converted into 41 | meters. See Details.} 42 | 43 | \item{...}{Currently not used.} 44 | 45 | \item{table}{Character string indicating the name of the table with 46 | the GPS data in the db3 container file.} 47 | } 48 | \description{ 49 | Read a training file in tcx, gpx, db3 or Golden Cheetah's JSON 50 | format 51 | } 52 | \details{ 53 | Available options for \code{speedunit} currently are 54 | \code{km_per_h}, \code{m_per_s}, \code{mi_per_h}, 55 | \code{ft_per_min} and \code{ft_per_s}. The default is 56 | \code{m_per_s} for TCX files and \code{km_per_h} for db3 and 57 | Golden Cheetah's json files. Available options for 58 | \code{distanceunit} currently are \code{km}, \code{m}, 59 | \code{mi} and \code{ft}. The default is \code{m} for TCX and 60 | \code{km} for gpx, db3 and Golden Cheetah's json files. 61 | 62 | \code{readTCX}, \code{readGPX}, \code{readGPX} and \code{readDB3}, 63 | try to identify the sport from the data in the container file. If 64 | that fails, then an attempt is made to guess the sport from 65 | keywords in the filename. If identification is not possible then 66 | the \code{file} attribute of the returned object has value 67 | \code{NA}. 68 | 69 | Reading Golden Cheetah's JSON files is experimental. 70 | } 71 | \examples{ 72 | ## read raw data 73 | filepath <- system.file("extdata/tcx", "2013-06-08-090442.TCX.gz", package = "trackeR") 74 | run0 <- readTCX(file = filepath, timezone = "GMT") 75 | 76 | ## turn into trackeRdata object 77 | units0 <- generate_units() 78 | run0 <- trackeRdata(run0, units = units0) 79 | 80 | ## alternatively 81 | \dontrun{ 82 | run0 <- read_container(filepath, type = "tcx", timezone = "GMT") 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /man/trackeR.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeR.R 3 | \docType{package} 4 | \name{trackeR} 5 | \alias{trackeR-package} 6 | \alias{trackeR} 7 | \title{trackeR: Infrastructure for running and cycling data from 8 | GPS-enabled tracking devices} 9 | \description{ 10 | trackeR provides infrastructure for handling cycling and running 11 | data from GPS-enabled tracking devices. After extraction and appropriate 12 | manipulation of the training or competition attributes, the data are placed into 13 | session-aware data objects with an S3 class trackeRdata. The information in the 14 | resultant data objects can then be visualised, summarised and analysed through 15 | corresponding flexible and extensible methods. 16 | } 17 | \note{ 18 | This work has been supported by the English Institute of Sport 19 | (currently UK Sports Institute) 20 | \url{https://uksportsinstitute.co.uk} and University College London 21 | (UCL), which jointly contributed to the grant that funded Hannah 22 | Frick's Post Doctoral Research Fellowship at UCL between 2014 and 23 | 2016 and a percentage of Ioannis Kosmidis' time. Ioannis Kosmidis 24 | has also been supported by the Alan Turing Institute under the 25 | EPSRC grant EP/N510129/1 (Turing award number TU/B/000082). The 26 | support of the aforementioned organisations is greatly 27 | acknowledged. 28 | 29 | Hannah Frick maintained trackeR from its first release up and since 30 | version 1.0.0. 31 | } 32 | \section{Note}{ 33 | 34 | 35 | Core facilities in the trackeR package, including reading functions 36 | (see \code{\link{readX}}), data pre-processing strategies (see 37 | \code{\link{trackeRdata}}), and calculation of concentration and 38 | distribution profiles (see \code{\link{distributionProfile}} and 39 | \code{\link{concentrationProfile}}) are based on un-packaged R code 40 | that was developed by Ioannis Kosmidis for the requirements of the 41 | analyses in Kosmidis & Passfield (2015). 42 | } 43 | 44 | \references{ 45 | Frick, H., Kosmidis, I. (2017). trackeR: Infrastructure for Running 46 | and Cycling Data from GPS-Enabled Tracking Devices in 47 | R. \emph{Journal of Statistical Software}, \bold{82}(7), 48 | 1--29. doi:10.18637/jss.v082.i07 49 | 50 | Kosmidis, I., and Passfield, L. (2015). Linking the Performance of 51 | Endurance Runners to Training and Physiological Effects via 52 | Multi-Resolution Elastic Net. \emph{ArXiv e-print} 53 | arXiv:1506.01388. 54 | } 55 | \seealso{ 56 | Useful links: 57 | \itemize{ 58 | \item \url{https://github.com/trackerproject/trackeR} 59 | \item Report bugs at \url{https://github.com/trackerproject/trackeR/issues} 60 | } 61 | 62 | } 63 | \author{ 64 | \strong{Maintainer}: Ioannis Kosmidis \email{ioannis.kosmidis@warwick.ac.uk} (\href{https://orcid.org/0000-0003-1556-0302}{ORCID}) 65 | 66 | Authors: 67 | \itemize{ 68 | \item Hannah Frick \email{hannah.frick@gmail.com} (\href{https://orcid.org/0000-0002-6049-5258}{ORCID}) 69 | \item Robin Hornak \email{robinhornak@gmail.com} 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /man/plot.trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata_plot.R 3 | \name{plot.trackeRdata} 4 | \alias{plot.trackeRdata} 5 | \title{Plot training sessions in form of trackeRdata objects} 6 | \usage{ 7 | \method{plot}{trackeRdata}( 8 | x, 9 | session = NULL, 10 | what = c("pace", "heart_rate"), 11 | threshold = TRUE, 12 | smooth = FALSE, 13 | trend = TRUE, 14 | dates = TRUE, 15 | unit_reference_sport = NULL, 16 | moving_threshold = NULL, 17 | ... 18 | ) 19 | } 20 | \arguments{ 21 | \item{x}{An object of class \code{\link{trackeRdata}}.} 22 | 23 | \item{session}{A numeric vector of the sessions to be plotted, 24 | defaults to all sessions.} 25 | 26 | \item{what}{Which variables should be plotted? A vector with at least one of \code{"latitude"}, \code{"longitude"}, \code{"altitude"}, \code{"distance"}, \code{"heart_rate"}, \code{"speed"}, \code{"cadence_running"}, \code{"cadence_cycling"}, \code{"power"}, \code{"temperature"}, \code{"pace"}, \code{"cumulative_elevation_gain"}. Default is \code{c("pace", "heart_rate")}.} 27 | 28 | \item{threshold}{Logical. Should thresholds be applied?} 29 | 30 | \item{smooth}{Logical. Should the data be smoothed?} 31 | 32 | \item{trend}{Logical. Should a smooth trend be plotted?} 33 | 34 | \item{dates}{Logical. Should the date of the session be used in the 35 | panel header?} 36 | 37 | \item{unit_reference_sport}{The sport to inherit units from 38 | (default is taken to be the most frequent sport in 39 | \code{object}).} 40 | 41 | \item{moving_threshold}{A named vector of 3 speeds to be used for 42 | thresholding pace, given in the unit of the speed measurements 43 | in \code{object}. If \code{NULL} (default), the speeds are 44 | taken to be \code{c(cycling = 2, running = 1, swimming = 45 | 0.5)}. See Details.} 46 | 47 | \item{...}{Further arguments to be passed to 48 | \code{\link{threshold}} and 49 | \code{\link{smootherControl.trackeRdata}}.} 50 | } 51 | \description{ 52 | Plot training sessions in form of trackeRdata objects 53 | } 54 | \details{ 55 | Note that a threshold is always applied to the pace. This (upper) 56 | threshold corresponds to a speed of 1.4 meters per second, the 57 | preferred walking speed of humans. The lower threshold is 0. 58 | 59 | The units for the variables match those of the sport specified by 60 | \code{unit_reference_sport}. 61 | } 62 | \examples{ 63 | \dontrun{ 64 | data('runs', package = 'trackeR') 65 | ## plot heart rate and pace for the first 3 sessions 66 | plot(runs, session = 1:3) 67 | ## plot raw speed data for session 4 68 | plot(runs, session = 4, what = "speed", threshold = FALSE, smooth = FALSE) 69 | ## threshold speed variable 70 | plot(runs, session = 4, what = "speed", threshold = TRUE, smooth = FALSE, 71 | variable = "speed", lower = 0, upper = 10) 72 | ## and smooth (thresholding with default values) 73 | plot(runs, session = 4, what = "speed", threshold = TRUE, 74 | smooth = TRUE, width = 15, parallel = FALSE) 75 | #' 76 | ## Speed and elevation gain 77 | plot(runs, session = 2:10, what = c("speed", "cumulative_elevation_gain"), trend = FALSE) 78 | } 79 | 80 | } 81 | \seealso{ 82 | trackeRdata 83 | } 84 | -------------------------------------------------------------------------------- /tests/testthat/test-reading.R: -------------------------------------------------------------------------------- 1 | context("implementation [reading tcx, gpx and json files]") 2 | 3 | tcxfile <- system.file("extdata/tcx/", "2013-06-30-070511.TCX.gz", package = "trackeR") 4 | gpxfile_run <- system.file("extdata/gpx/", "20170708-154835-Run.gpx.gz", package = "trackeR") 5 | gpxfile_ride <- system.file("extdata/gpx/", "20170709-151453-Ride.gpx.gz", package = "trackeR") 6 | gpxfile_swim <- system.file("extdata/gpx/", "20170714-143644-Swim.gpx.gz", package = "trackeR") 7 | jsonfile <- system.file("extdata/json/", "2017_04_24_10_18_45.json.gz", package = "trackeR") 8 | 9 | ## tcx 10 | tcx <- readTCX(tcxfile) 11 | test_that("tcx file is read correctly [result is a data.frame]", { 12 | expect_is(tcx, "data.frame") 13 | }) 14 | test_that("tcx file is read correctly [time, gps, cadence and sport]", { 15 | expect_equal(attr(tcx, "sport"), "running") 16 | expect_true(all(is.na(tcx$cadence_cycling))) 17 | expect_false(all(is.na(tcx$cadence_running))) 18 | expect_is(tcx$time, "POSIXct") 19 | expect_false(all(is.na(tcx$latitude))) 20 | expect_false(all(is.na(tcx$longitude))) 21 | 22 | }) 23 | 24 | ## gpx 25 | gpx_run <- readGPX(gpxfile_run) 26 | gpx_ride <- readGPX(gpxfile_ride) 27 | gpx_swim <- readGPX(gpxfile_swim) 28 | test_that("gpx file is read correctly [result is a data.frame]", { 29 | expect_is(gpx_run, "data.frame") 30 | expect_is(gpx_ride, "data.frame") 31 | expect_is(gpx_swim, "data.frame") 32 | }) 33 | test_that("gpx file is read correctly [time, gps, cadence and sport]", { 34 | expect_equal(attr(gpx_run, "sport"), "running") 35 | expect_equal(attr(gpx_swim, "sport"), "swimming") 36 | expect_equal(attr(gpx_ride, "sport"), "cycling") 37 | expect_is(gpx_run$time, "POSIXct") 38 | expect_false(all(is.na(gpx_run$latitude))) 39 | expect_false(all(is.na(gpx_run$longitude))) 40 | expect_is(gpx_ride$time, "POSIXct") 41 | expect_false(all(is.na(gpx_ride$latitude))) 42 | expect_false(all(is.na(gpx_ride$longitude))) 43 | expect_is(gpx_swim$time, "POSIXct") 44 | expect_false(all(is.na(gpx_swim$latitude))) 45 | expect_false(all(is.na(gpx_swim$longitude))) 46 | ## There is cadence in the cycling file 47 | expect_true(all(is.na(gpx_run$cadence_cycling))) 48 | expect_false(all(is.na(gpx_run$cadence_running))) 49 | ## No cadence in the ride file 50 | expect_true(all(is.na(gpx_ride$cadence_cycling))) 51 | expect_true(all(is.na(gpx_ride$cadence_running))) 52 | ## No cadence in the swim file 53 | expect_true(all(is.na(gpx_swim$cadence_cycling))) 54 | expect_true(all(is.na(gpx_swim$cadence_running))) 55 | }) 56 | 57 | ## json 58 | test_that("json file is read correctly [result is a data.frame]", { 59 | expect_warning(json <- readJSON(jsonfile)) 60 | expect_is(json, "data.frame") 61 | }) 62 | test_that("json file is read correctly [time, gps, cadence and sport]", { 63 | expect_warning(json <- readJSON(jsonfile)) 64 | expect_equal(attr(json, "sport"), "cycling") 65 | expect_false(all(is.na(json$cadence_cycling))) 66 | expect_true(all(is.na(json$cadence_running))) 67 | expect_true(all(is.na(json$latitude))) 68 | expect_true(all(is.na(json$longitude))) 69 | expect_is(json$time, "POSIXct") 70 | }) 71 | 72 | -------------------------------------------------------------------------------- /man/distribution_profile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/distributionProfile.R, R/zzz_aliases.R 3 | \name{distribution_profile} 4 | \alias{distribution_profile} 5 | \alias{distrProfile} 6 | \alias{distributionProfile} 7 | \title{Generate training distribution profiles.} 8 | \usage{ 9 | distribution_profile( 10 | object, 11 | session = NULL, 12 | what = NULL, 13 | grid = NULL, 14 | parallel = FALSE, 15 | unit_reference_sport = NULL 16 | ) 17 | 18 | distributionProfile( 19 | object, 20 | session = NULL, 21 | what = NULL, 22 | grid = NULL, 23 | parallel = FALSE, 24 | unit_reference_sport = NULL 25 | ) 26 | } 27 | \arguments{ 28 | \item{object}{An object of class \code{\link{trackeRdata}}.} 29 | 30 | \item{session}{A numeric vector of the sessions to be used, 31 | defaults to all sessions.} 32 | 33 | \item{what}{The variables for which the distribution profiles 34 | should be generated. Defaults to all variables in 35 | \code{object} (\code{what = NULL}).} 36 | 37 | \item{grid}{A named list containing the grid values for the 38 | variables in \code{what}. If \code{NULL} (default) the grids 39 | for the variables in \code{what} are inferred from 40 | \code{object}.} 41 | 42 | \item{parallel}{Logical. Should computation be carried out in 43 | parallel? Default is \code{FALSE}.} 44 | 45 | \item{unit_reference_sport}{The sport to inherit units from 46 | (default is taken to be the most frequent sport in 47 | \code{object}).} 48 | } 49 | \value{ 50 | An object of class \code{distrProfile}. 51 | 52 | Object: 53 | 54 | A named list with one or more components, corresponding to the 55 | value of \code{what}. Each component is a matrix of dimension 56 | \code{g} times \code{n}, where \code{g} is the length of the grids 57 | set in \code{grid} (or 201 if \code{grid = NULL}) and \code{n} is 58 | the number of sessions requested in the \code{session} argument. 59 | 60 | Attributes: 61 | 62 | Each \code{distrProfile} object has the following attributes: 63 | 64 | \itemize{ 65 | 66 | \item \code{sport}: the sports corresponding to the columns of each 67 | list component 68 | 69 | \item \code{session_times}: the session start and end times 70 | corresponding to the columns of each list component 71 | 72 | \item \code{unit_reference_sport}: the sport where the units have 73 | been inherited from 74 | 75 | \item \code{operations}: a list with the operations that have been 76 | applied to the object. See \code{\link{get_operations.distrProfile}} 77 | 78 | \item \code{limits}: The variable limits that have been used for the 79 | computation of the distribution profiles 80 | 81 | \item \code{units}: an object listing the units used for the 82 | calculation of distribution profiles. These is the output of 83 | \code{\link{get_units}} on the corresponding 84 | \code{\link{trackeRdata}} object, after inheriting units from 85 | \code{unit_reference_sport}. 86 | 87 | } 88 | } 89 | \description{ 90 | Generate training distribution profiles. 91 | } 92 | \examples{ 93 | data('run', package = 'trackeR') 94 | dProfile <- distribution_profile(run, what = c("speed", "cadence_running")) 95 | \dontrun{ 96 | plot(dProfile, smooth = FALSE) 97 | } 98 | } 99 | \references{ 100 | Kosmidis, I., and Passfield, L. (2015). Linking the Performance of 101 | Endurance Runners to Training and Physiological Effects via 102 | Multi-Resolution Elastic Net. \emph{ArXiv e-print} 103 | arXiv:1506.01388. 104 | 105 | Frick, H., Kosmidis, I. (2017). trackeR: Infrastructure for Running 106 | and Cycling Data from GPS-Enabled Tracking Devices in 107 | R. \emph{Journal of Statistical Software}, \bold{82}(7), 108 | 1--29. doi:10.18637/jss.v082.i07 109 | } 110 | -------------------------------------------------------------------------------- /man/concentration_profile.distrProfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/concentrationProfile.R 3 | \name{concentration_profile.distrProfile} 4 | \alias{concentration_profile.distrProfile} 5 | \alias{conProfile} 6 | \alias{concentration_profile.trackeRdata} 7 | \title{Generate training concentration profiles.} 8 | \usage{ 9 | \method{concentration_profile}{distrProfile}(object, session = NULL, what = NULL, ...) 10 | 11 | \method{concentration_profile}{trackeRdata}( 12 | object, 13 | session = NULL, 14 | what = NULL, 15 | limits = NULL, 16 | parallel = FALSE, 17 | unit_reference_sport = NULL, 18 | scale = FALSE, 19 | ... 20 | ) 21 | } 22 | \arguments{ 23 | \item{object}{An object of class \code{\link{trackeRdata}} or \code{\link{distrProfile}}.} 24 | 25 | \item{session}{A numeric vector of the sessions to be used, 26 | defaults to all sessions.} 27 | 28 | \item{what}{The variables for which the distribution profiles 29 | should be generated. Defaults to all variables in \code{object} 30 | (\code{what = NULL}).} 31 | 32 | \item{...}{Currently not used.} 33 | 34 | \item{limits}{A named list of vectors of two numbers to specify the 35 | lower and upper limits for the variables in \code{what}. If 36 | \code{NULL} (default) the limits for the variables in 37 | \code{what} are inferred from \code{object}.} 38 | 39 | \item{parallel}{Logical. Should computation be carried out in 40 | parallel? Default is \code{FALSE}.} 41 | 42 | \item{unit_reference_sport}{The sport to inherit units from 43 | (default is taken to be the most frequent sport in 44 | \code{object}).} 45 | 46 | \item{scale}{Logical. If \code{FALSE} (default) then the integral 47 | of the profiles over the real line matches the session length.} 48 | } 49 | \value{ 50 | An object of class \code{conProfile}. 51 | 52 | Object: 53 | 54 | A named list with one or more components, corresponding to the 55 | value of \code{what}. Each component is a matrix of dimension 56 | \code{g} times \code{n}, where \code{g} is the length of the grids 57 | set in \code{grid} (or 200 if \code{grid = NULL}) and \code{n} is 58 | the number of sessions requested in the \code{session} argument. 59 | 60 | Attributes: 61 | 62 | Each \code{conProfile} object has the following attributes: 63 | 64 | \itemize{ 65 | 66 | \item \code{sport}: the sports corresponding to the columns of each 67 | list component 68 | 69 | \item \code{session_times}: the session start and end times 70 | corresponding to the columns of each list component 71 | 72 | \item \code{unit_reference_sport}: the sport where the units have 73 | been inherited from 74 | 75 | \item \code{operations}: a list with the operations that have been 76 | applied to the object. See \code{\link{get_operations.distrProfile}} 77 | 78 | \item \code{limits}: The variable limits that have been used for the 79 | computation of the concentration profiles. 80 | 81 | \item \code{units}: an object listing the units used for the 82 | calculation of distribution profiles. These is the output of 83 | \code{\link{get_units}} on the corresponding 84 | \code{\link{trackeRdata}} object, after inheriting units from 85 | \code{unit_reference_sport}. 86 | 87 | } 88 | } 89 | \description{ 90 | Generate training concentration profiles. 91 | } 92 | \references{ 93 | Kosmidis, I., and Passfield, L. (2015). Linking the Performance of 94 | Endurance Runners to Training and Physiological Effects via 95 | Multi-Resolution Elastic Net. \emph{ArXiv e-print} 96 | arXiv:1506.01388. 97 | 98 | Frick, H., Kosmidis, I. (2017). trackeR: Infrastructure for Running 99 | and Cycling Data from GPS-Enabled Tracking Devices in 100 | R. \emph{Journal of Statistical Software}, \bold{82}(7), 101 | 1--29. doi:10.18637/jss.v082.i07 102 | } 103 | -------------------------------------------------------------------------------- /tests/testthat/test-units.R: -------------------------------------------------------------------------------- 1 | context("implementation of units [generation, change]") 2 | 3 | test_that("generate units returns the right units [defaults]", { 4 | un <- generate_units() 5 | expect_equal(dim(subset(un, sport == "running" & variable == "cadence_cycling")), c(0, 3)) 6 | run <- c("latitude", "longitude", "altitude", "distance", "heart_rate", "speed", 7 | "cadence_running", "temperature", "pace", "duration") 8 | expect_true(all(subset(un, sport == "running")$variable %in% run)) 9 | expect_equal(dim(subset(un, sport == "cycling" & variable == "cadence_running")), c(0, 3)) 10 | expect_equal(dim(subset(un, sport == "cycling" & variable == "cadence_cycling")), c(1, 3)) 11 | }) 12 | 13 | test_that("generate units returns correct units [user specified]", { 14 | expect_error(generate_units(variable = "cadence", sport = "cycling", unit = "rev_per_min")) 15 | expect_error(generate_units(variable = "cadence_cycling", sport = "running", unit = "rev_per_min")) 16 | un <- generate_units(variable = c("speed", "altitude", "distance"), 17 | sport = c("cycling", "running", "cycling"), 18 | unit = c("mi_per_h", "km", "ft")) 19 | expect_equal(subset(un, sport == "cycling" & variable == "speed")$unit, "mi_per_h") 20 | expect_equal(subset(un, sport == "cycling" & variable == "distance")$unit, "ft") 21 | expect_equal(subset(un, sport == "running" & variable == "altitude")$unit, "km") 22 | }) 23 | 24 | gpxfile_run <- system.file("extdata/gpx/", "20170708-154835-Run.gpx.gz", package = "trackeR") 25 | gpxfile_ride <- system.file("extdata/gpx/", "20170709-151453-Ride.gpx.gz", package = "trackeR") 26 | test_that("change units works as expected []", { 27 | gpxa <- read_container(gpxfile_run, type = "gpx") 28 | gpxb <- read_container(gpxfile_ride, type = "gpx") 29 | gpxa1 <- change_units(gpxa, 30 | variable = "speed", 31 | unit = "mi_per_h", 32 | sport = "cycling") 33 | expect_equal(gpxa1, gpxa, check.attributes = FALSE) 34 | gpxb1 <- change_units(gpxb, 35 | variable = c("speed", "distance", "temperature", "altitude", "temperature"), 36 | unit = c("mi_per_h", "km", "F", "ft", "F"), 37 | sport = c("cycling", "cycling", "running", "swimming", "cycling")) 38 | expect_equal(gpxb1[[1]]$speed, gpxb[[1]]$speed/1609.344 * 60 * 60) 39 | expect_equal(gpxb1[[1]]$distance, gpxb[[1]]$distance/1000) 40 | u <- getUnits(gpxb1) 41 | expect_equal(u[u$variable == "temperature" & u$sport == "cycling", "unit"], "F") 42 | expect_equal(u[u$variable == "temperature" & u$sport == "running", "unit"], "F") 43 | expect_equal(u[u$variable == "temperature" & u$sport == "swimming", "unit"], "C") 44 | expect_equal(u[u$variable == "altitude" & u$sport == "cycling", "unit"], "m") 45 | expect_equal(u[u$variable == "altitude" & u$sport == "running", "unit"], "m") 46 | expect_equal(u[u$variable == "altitude" & u$sport == "swimming", "unit"], "ft") 47 | expect_error(gpxa1 <- change_units(gpxa, 48 | variable = "speed", 49 | unit = "sad", 50 | sport = "cycling")) 51 | expect_error(gpxa1 <- change_units(gpxa, 52 | variable = "speed", 53 | unit = "m_per_s", 54 | sport = "hiking")) 55 | attr(gpxa, "sport") <- NA 56 | expect_error(change_units(gpxa, "distance", "m", "running")) 57 | }) 58 | 59 | data("runs", package = "trackeR") 60 | test_that("threshold works with all vairables", { 61 | un <- generate_units() 62 | expect_equal(nsessions(change_units(runs, un$variable, un$unit, un$sport)), nsessions(runs)) 63 | }) 64 | -------------------------------------------------------------------------------- /tests/testthat/test-concentration_profile.R: -------------------------------------------------------------------------------- 1 | context("implementation [distribution_profile, class, extractors, methods]") 2 | 3 | test_that("concentration_profile works as expected [trackeRdata; computation and methods]", { 4 | 5 | gpx <- system.file("extdata/gpx/", package = "trackeR") 6 | obj <- read_directory(gpx, silent = TRUE, verbose = FALSE) 7 | 8 | vars <- c(generate_variable_names()$human_names, "pace") 9 | expect_warning(cp <- concentration_profile(obj, what = vars), "no data|time|heart_rate|cadence_cycling") 10 | expect_warning(sm_cp <- smoother(cp, what = c("speed", "pace"))) 11 | 12 | expect_true(all(names(cp) %in% vars)) 13 | expect_equal(names(sm_cp), c("speed", "pace")) 14 | 15 | expect_equal(get_sport(cp), c("running", "cycling", "swimming")) 16 | expect_equal(get_sport(sm_cp), c("running", "cycling", "swimming")) 17 | 18 | expect_equal(get_operations(sm_cp)$smooth, "density") 19 | expect_true(!get_operations(sm_cp)$scale) 20 | 21 | expect_equal(attr(cp, "unit_reference_sport"), "cycling") 22 | expect_equal(attr(sm_cp, "unit_reference_sport"), "cycling") 23 | 24 | expect_equal(attr(cp, "session_times"), session_times(obj)) 25 | expect_equal(attr(sm_cp, "session_times"), session_times(obj)) 26 | 27 | ## subset 28 | cps <- get_profile(cp, session = c(1, 3), what = c("speed", "pace")) 29 | 30 | expect_equal(colnames(cps$speed), c("session1", "session3")) 31 | expect_equal(names(cps), c("speed", "pace")) 32 | 33 | att <- attributes(cp) 34 | atts <- attributes(cps) 35 | 36 | expect_equal(att$unit_reference_sport, atts$unit_reference_sport) 37 | expect_equal(att$operations, atts$operations) 38 | expect_equal(att$units, atts$units) 39 | expect_equal(att$sport[-2], atts$sport) 40 | expect_equal(att$session_times[-2, ], atts$session_times) 41 | 42 | expect_equal(class(cp), "conProfile") 43 | expect_equal(class(sm_cp), "conProfile") 44 | 45 | }) 46 | 47 | 48 | test_that("concentration_profile works as expected [distrProfile; computation and methods]", { 49 | 50 | gpx <- system.file("extdata/gpx/", package = "trackeR") 51 | obj <- read_directory(gpx, silent = TRUE, verbose = FALSE) 52 | 53 | vars <- c(generate_variable_names()$human_names, "pace") 54 | expect_warning(dp <- distribution_profile(obj, what = vars), "no data|time|heart_rate|cadence_cycling") 55 | sm_dp <- smoother(dp, what = c("speed", "pace")) 56 | sc_dp <- scaled(dp, what = c("speed", "pace")) 57 | 58 | cp <- concentration_profile(sm_dp) 59 | sm_cp <- concentration_profile(sm_dp) 60 | sc_cp <- concentration_profile(sc_dp) 61 | 62 | 63 | expect_true(all(names(cp) %in% vars)) 64 | expect_equal(names(sm_cp), c("speed", "pace")) 65 | 66 | expect_equal(get_sport(cp), c("running", "cycling", "swimming")) 67 | expect_equal(get_sport(sm_cp), c("running", "cycling", "swimming")) 68 | 69 | expect_equal(get_operations(sm_cp)$smooth, list(k = 30, sp = NULL, parallel = FALSE)) 70 | expect_true(!get_operations(sm_cp)$scale) 71 | 72 | expect_equal(attr(cp, "unit_reference_sport"), "cycling") 73 | expect_equal(attr(sm_cp, "unit_reference_sport"), "cycling") 74 | 75 | expect_equal(attr(cp, "session_times"), session_times(obj)) 76 | expect_equal(attr(sm_cp, "session_times"), session_times(obj)) 77 | 78 | ## subset 79 | cps <- get_profile(cp, session = c(1, 3), what = c("speed", "pace")) 80 | 81 | expect_equal(colnames(cps$speed), c("session1", "session3")) 82 | expect_equal(names(cps), c("speed", "pace")) 83 | 84 | att <- attributes(cp) 85 | atts <- attributes(cps) 86 | 87 | expect_equal(att$unit_reference_sport, atts$unit_reference_sport) 88 | expect_equal(att$operations, atts$operations) 89 | expect_equal(att$units, atts$units) 90 | expect_equal(att$sport[-2], atts$sport) 91 | expect_equal(att$session_times[-2, ], atts$session_times) 92 | 93 | expect_equal(class(cp), "conProfile") 94 | expect_equal(class(sm_cp), "conProfile") 95 | expect_equal(class(sc_cp), "conProfile") 96 | 97 | }) 98 | -------------------------------------------------------------------------------- /man/trackeRdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trackeRdata.R 3 | \name{trackeRdata} 4 | \alias{trackeRdata} 5 | \title{Create a trackeRdata object} 6 | \usage{ 7 | trackeRdata( 8 | dat, 9 | units = NULL, 10 | sport = NULL, 11 | session_threshold = 2, 12 | correct_distances = FALSE, 13 | smooth_elevation_gain = TRUE, 14 | from_distances = TRUE, 15 | country = NULL, 16 | mask = TRUE, 17 | lgap = 30, 18 | lskip = 5, 19 | m = 11, 20 | silent = FALSE 21 | ) 22 | } 23 | \arguments{ 24 | \item{dat}{A \code{\link{data.frame}} object.} 25 | 26 | \item{units}{The output of \code{\link{generate_units}}.} 27 | 28 | \item{sport}{What sport does \code{dat} contain data of? Either 29 | \code{'cycling'}, \code{'running'}, \code{'swimming'} or 30 | \code{NULL} (default), in which case the sport is directly 31 | extracted from the \code{dat}. See Details.} 32 | 33 | \item{session_threshold}{The threshold in hours for the time 34 | difference between consecutive timestamps above which they are 35 | considered to belong to different training sessions.} 36 | 37 | \item{correct_distances}{Logical. Should the distances be corrected 38 | for elevation? Default is \code{FALSE}.} 39 | 40 | \item{smooth_elevation_gain}{Logical. Should the elevation gain be 41 | smoothed before computing elevation gain? Default 42 | is \code{TRUE}.} 43 | 44 | \item{from_distances}{Logical. Should the speeds be calculated from the distance recordings 45 | instead of taken from the speed recordings directly?} 46 | 47 | \item{country}{ISO3 country code for downloading altitude data. If 48 | \code{NULL}, country is derived from longitude and latitude} 49 | 50 | \item{mask}{Logical. Passed on to 51 | \code{\link[raster]{getData}}. Should only the altitudes for 52 | the specified \code{country} be extracted (\code{TRUE}) or also 53 | those for the neighbouring countries (\code{FALSE})?} 54 | 55 | \item{lgap}{Time in seconds corresponding to the minimal sampling rate.} 56 | 57 | \item{lskip}{Time in seconds between the last observation before a small break 58 | and the first imputed speed or the last imputed speed and the first 59 | observation after a small break.} 60 | 61 | \item{m}{Number of imputed observations in each small break.} 62 | 63 | \item{silent}{Logical. Should warnings be generated if any of the 64 | sanity checks on the data are triggered?} 65 | } 66 | \description{ 67 | Create a trackeRdata object from a data frame with observations 68 | being divided in separate training sessions. For breaks within a 69 | session observations are imputed. 70 | } 71 | \details{ 72 | During small breaks within a session, e.g., because the recording 73 | device was paused, observations are imputed the following way: 0 74 | for speed, last known position for latitude, longitude and 75 | altitude, NA or 0 power for running or cycling session, 76 | respectively, and NA for all other variables. Distances are 77 | (re-)calculated based on speeds after imputation. 78 | 79 | \code{trackeRdata} assumes that all observations in \code{dat} are 80 | from the same \code{sport}, even if \code{dat} ends up having 81 | observations from different sessions (also depending on the value 82 | of \code{session_threshold}. 83 | 84 | if \code{attr(dat, 'sport')} is \code{NA} then the current 85 | implementation of \code{trackeRdata} returns an error. 86 | 87 | More details about the resulting \code{trackeRdata} object are 88 | available in the package vignette, which is an up-to-date version 89 | of Frick & Kosmidis (2017). 90 | } 91 | \examples{ 92 | ## read raw data 93 | filepath <- system.file('extdata/tcx/', '2013-06-08-090442.TCX.gz', package = 'trackeR') 94 | run0 <- readTCX(file = filepath, timezone = 'GMT') 95 | 96 | ## turn into trackeRdata object 97 | units0 <- generate_units() 98 | run0 <- trackeRdata(run0, units = units0) 99 | } 100 | \references{ 101 | Frick, H., Kosmidis, I. (2017). trackeR: Infrastructure for Running 102 | and Cycling Data from GPS-Enabled Tracking Devices in 103 | R. \emph{Journal of Statistical Software}, \bold{82}(7), 104 | 1--29. doi:10.18637/jss.v082.i07 105 | } 106 | \seealso{ 107 | \code{\link{readContainer}} for reading .tcx and .db3 108 | files directly into \code{trackeRdata} objects, and 109 | \code{\link{get_elevation_gain}} for details on the computation 110 | of the elevation gain. 111 | } 112 | -------------------------------------------------------------------------------- /man/Wprime.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Wprime.R 3 | \name{Wprime} 4 | \alias{Wprime} 5 | \alias{trackeRWprime} 6 | \alias{Based} 7 | \alias{on} 8 | \alias{the} 9 | \alias{critical} 10 | \alias{power} 11 | \alias{model} 12 | \alias{for} 13 | \alias{cycling} 14 | \alias{(Monod} 15 | \alias{and} 16 | \alias{Scherrer,} 17 | \alias{1965),} 18 | \alias{W'} 19 | \alias{(read} 20 | \alias{W} 21 | \alias{prime)} 22 | \alias{describes} 23 | \alias{finite} 24 | \alias{work} 25 | \alias{capacity} 26 | \alias{above} 27 | \alias{(Skiba} 28 | \alias{et} 29 | \alias{al.,} 30 | \alias{2012).} 31 | \alias{While} 32 | \alias{is} 33 | \alias{depleted} 34 | \alias{during} 35 | \alias{exercise} 36 | \alias{power,} 37 | \alias{it} 38 | \alias{replenished} 39 | \alias{below} 40 | \alias{power.} 41 | \alias{Thus,} 42 | \alias{of} 43 | \alias{interest} 44 | \alias{how} 45 | \alias{much} 46 | \alias{this} 47 | \alias{has} 48 | \alias{been} 49 | \alias{not} 50 | \alias{yet} 51 | \alias{replinished} 52 | \alias{again,} 53 | \alias{named} 54 | \alias{expended,} 55 | \alias{or} 56 | \alias{still} 57 | \alias{available,} 58 | \alias{balance.} 59 | \alias{This} 60 | \alias{principal} 61 | \alias{applied} 62 | \alias{to} 63 | \alias{runners} 64 | \alias{by} 65 | \alias{subsituting} 66 | \alias{with} 67 | \alias{speed} 68 | \alias{speed,} 69 | \alias{respectively} 70 | \title{W': work capacity above critical power/speed.} 71 | \usage{ 72 | Wprime( 73 | object, 74 | session = NULL, 75 | quantity = c("expended", "balance"), 76 | w0, 77 | cp, 78 | version = c("2015", "2012"), 79 | meanRecoveryPower = FALSE, 80 | parallel = FALSE, 81 | ... 82 | ) 83 | } 84 | \arguments{ 85 | \item{object}{A \code{\link{trackeRdata}} object.} 86 | 87 | \item{session}{A numeric vector of the sessions to be used, 88 | defaults to all sessions.} 89 | 90 | \item{quantity}{Should W' \code{'expended'} or W' \code{'balance'} 91 | be returned?} 92 | 93 | \item{w0}{Initial capacity of W', as calculated based on the 94 | critical power model by Monod and Scherrer (1965).} 95 | 96 | \item{cp}{Critical power/speed, i.e., the power/speed which can be 97 | maintained for longer period of time.} 98 | 99 | \item{version}{How should W' be replenished? Options include 100 | \code{'2015'} and \code{'2012'} for the versions presented in 101 | Skiba et al. (2015) and Skiba et al. (2012), respectively. See 102 | Details.} 103 | 104 | \item{meanRecoveryPower}{Should the mean of all power outputs below 105 | critical power be used as recovery power? See Details.} 106 | 107 | \item{parallel}{Logical. Should computation be carried out in 108 | parallel? If \code{TRUE} computation is performed in parallel 109 | using the backend provided to \pkg{foreach}. Default is 110 | \code{FALSE}.} 111 | 112 | \item{...}{Currently not used.} 113 | } 114 | \value{ 115 | An object of class \code{trackeRWprime}. 116 | } 117 | \description{ 118 | W': work capacity above critical power/speed. 119 | } 120 | \details{ 121 | #' Skiba et al. (2015) and Skiba et al. (2012) both describe an 122 | exponential decay of \eqn{W'} expended over an interval 123 | \eqn{[t_{i-1}, t_i)} if the power output during this interval is 124 | below critical power: 125 | 126 | \deqn{W_exp (t_i) = W_exp(t_{i-1}) * exp(nu * (t_i - t_{i-1}))} 127 | 128 | However, the factor nu differs: Skiba et al. (2012) describe it as 129 | \eqn{1/\tau} with \eqn{\tau} estimated as 130 | 131 | \deqn{tau = 546 * exp(-0.01 * (CP - P_i)) + 316} 132 | 133 | Skiba et al. (2015) use \eqn{(P_i - CP) / W'_0}. Skiba et 134 | al. (2012) and Skiba et al. (2015) employ a constant recovery power 135 | (calculated as the mean over all power outputs below critical 136 | power). This rationale can be applied by setting the argument 137 | \code{meanRecoveryPower} to \code{TRUE}. Note that this uses 138 | information from all observations with a power output below 139 | critical power, not just those prior to the current time point. 140 | } 141 | \examples{ 142 | \dontrun{ 143 | data('runs', package = 'trackeR') 144 | wexp <- Wprime(runs, session = c(11,13), cp = 4, version = '2012') 145 | plot(wexp) 146 | } 147 | } 148 | \references{ 149 | Monod H, Scherrer J (1965). 'The Work Capacity of a Synergic 150 | Muscular Group.' Ergonomics, 8(3), 329--338. 151 | 152 | Skiba PF, Chidnok W, Vanhatalo A, Jones AM (2012). 'Modeling the 153 | Expenditure and Reconstitution of Work Capacity above Critical 154 | Power.' Medicine & Science in Sports & Exercise, 44(8), 1526--1532. 155 | 156 | Skiba PF, Fulford J, Clarke DC, Vanhatalo A, Jones AM 157 | (2015). 'Intramuscular Determinants of the Ability to Recover 158 | Work Capacity above Critical Power.' European Journal of Applied 159 | Physiology, 115(4), 703--713. 160 | } 161 | -------------------------------------------------------------------------------- /R/trackeRdata_smoother.R: -------------------------------------------------------------------------------- 1 | #' Smoother for \code{\link{trackeRdata}} objects. 2 | #' 3 | #' @param object An object of class \code{\link{trackeRdata}}. 4 | #' @param session The sessions to be smoothed. Default is all sessions. 5 | #' @param control A list of parameters for controlling the smoothing 6 | #' process. This is passed to \code{\link{smoother_control.trackeRdata}}. 7 | #' @param ... Arguments to be used to form the default \code{control} 8 | #' argument if it is not supplied directly. 9 | #' 10 | #' @return An object of class \code{\link{trackeRdata}}. 11 | #' 12 | #' @seealso \code{\link{smoother_control.trackeRdata}} 13 | #' 14 | #' @examples 15 | #' \dontrun{ 16 | #' data('run', package = 'trackeR') 17 | #' ## unsmoothed speeds 18 | #' plot(run, smooth = FALSE) 19 | #' ## default smoothing 20 | #' plot(run, smooth = TRUE) 21 | #' ## smoothed with some non-default options 22 | #' runS <- smoother(run, fun = 'median', width = 20, what = 'speed') 23 | #' plot(runS, smooth = FALSE) 24 | #' } 25 | #' @export 26 | smoother.trackeRdata <- function(object, 27 | session = NULL, 28 | control = list(...), 29 | ...) { 30 | 31 | operations <- attr(object, "operations") 32 | 33 | if (!is.null(operations$smooth)) { 34 | warning("'object' is already the result of smoother.") 35 | return(object) 36 | } 37 | 38 | ## select sessions 39 | if (is.null(session)) { 40 | session <- seq_len(length(object)) 41 | } 42 | object <- object[session] 43 | 44 | ## evaluate control argument 45 | control$nsessions <- length(session) 46 | control <- do.call("smoother_control.trackeRdata", control) 47 | 48 | ## Check that all what are available 49 | what <- match(unlist(control$what), names(object[[1]])) 50 | 51 | if (any(is.na(what))) { 52 | stop("At least one of 'what' is not available.") 53 | } 54 | 55 | smooth_fun <- function(j) { 56 | zoo::rollapply(object[[j]], width = control$width, match.fun(control$fun)) 57 | } 58 | 59 | foreach_object <- eval(as.call(c(list(quote(foreach::foreach), 60 | j = seq.int(nsessions(object)))))) 61 | 62 | if (control$parallel) { 63 | setup_parallel() 64 | objectNew <- foreach::`%dopar%`(foreach_object, smooth_fun(j)) 65 | } 66 | else { 67 | objectNew <- foreach::`%do%`(foreach_object, smooth_fun(j)) 68 | } 69 | 70 | ## replace variables not in control$what with the corresponding original data 71 | for (k in seq_len(length(object))) { 72 | inds <- index(objectNew[[k]]) 73 | objectNew[[k]][, -what] <- object[[k]][inds, -what] 74 | } 75 | 76 | class(objectNew) <- "trackeRdata" 77 | 78 | ## Enrich attr(objectNew, 'operations') with the control of the operation that has just 79 | ## been performed 80 | operations$smooth <- control 81 | attr(objectNew, "operations") <- operations 82 | attr(objectNew, "units") <- getUnits(object) 83 | attr(objectNew, "sport") <- get_sport(object) 84 | attr(objectNew, "file") <- attr(object, "file") 85 | return(objectNew) 86 | 87 | } 88 | 89 | #' Auxiliary function for \code{\link{smoother.trackeRdata}}. Typically used to construct 90 | #' a control argument for \code{\link{smoother.trackeRdata}}. 91 | #' 92 | #' @param fun The name of the function to be matched and used to 93 | #' aggregate/smooth the data. 94 | #' @param width The width of the window in which the raw observations 95 | #' get aggregated via function \code{fun}. 96 | #' @param parallel Logical. Should computation be carried out in 97 | #' parallel? If \code{TRUE} computation is performed in parallel 98 | #' using the backend provided to \pkg{foreach}. Default is 99 | #' \code{FALSE}. 100 | #' @param what Vector of the names of the variables which should be 101 | #' smoothed. 102 | #' @param nsessions Vector containing the number of session. Default 103 | #' corresponds to all sessions belonging to the same group. Used 104 | #' only internally. 105 | #' @param ... Currently not used. 106 | #' 107 | #' @seealso \code{\link{smoother.trackeRdata}} 108 | #' @export 109 | smoother_control.trackeRdata <- function(fun = "mean", 110 | width = 10, 111 | parallel = FALSE, 112 | what = c("speed", "heart_rate"), 113 | nsessions = NA, ...) { 114 | # Basic checks for the arguments 115 | if (!is.character(fun)) { 116 | stop("'fun' should be a character string") 117 | } else { 118 | match.fun(fun) 119 | } 120 | if (is.vector(what)) { 121 | what <- list(what) 122 | } 123 | list(fun = fun, width = width, parallel = parallel, what = what, nsessions = nsessions) 124 | } 125 | 126 | -------------------------------------------------------------------------------- /man/read_container.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/reading.R, R/zzz_aliases.R 3 | \name{read_container} 4 | \alias{read_container} 5 | \alias{readContainer} 6 | \title{Read a GPS container file.} 7 | \usage{ 8 | read_container( 9 | file, 10 | type = c("tcx", "gpx", "db3", "json"), 11 | table = "gps_data", 12 | timezone = "", 13 | session_threshold = 2, 14 | correct_distances = FALSE, 15 | smooth_elevation_gain = TRUE, 16 | country = NULL, 17 | mask = TRUE, 18 | from_distances = NULL, 19 | speedunit = NULL, 20 | distanceunit = NULL, 21 | sport = NULL, 22 | lgap = 30, 23 | lskip = 5, 24 | m = 11, 25 | silent = FALSE 26 | ) 27 | 28 | readContainer( 29 | file, 30 | type = c("tcx", "gpx", "db3", "json"), 31 | table = "gps_data", 32 | timezone = "", 33 | session_threshold = 2, 34 | correct_distances = FALSE, 35 | smooth_elevation_gain = TRUE, 36 | country = NULL, 37 | mask = TRUE, 38 | from_distances = NULL, 39 | speedunit = NULL, 40 | distanceunit = NULL, 41 | sport = NULL, 42 | lgap = 30, 43 | lskip = 5, 44 | m = 11, 45 | silent = FALSE 46 | ) 47 | } 48 | \arguments{ 49 | \item{file}{The path to a tcx, gpx, json or db3 file. Compressed 50 | versions (gz, bz2, xz, zip) of tcx, gpx, and json files are 51 | directly supported.} 52 | 53 | \item{type}{The type of the GPS container file. Supported so far 54 | are \code{tcx}, \code{db3}, and \code{json}.} 55 | 56 | \item{table}{The name of the table in the database if \code{type} 57 | is set to \code{db3}, ignored otherwise.} 58 | 59 | \item{timezone}{The timezone of the observations as passed on to 60 | \code{\link[base]{as.POSIXct}}. Ignored for JSON files.} 61 | 62 | \item{session_threshold}{The threshold in hours for the time 63 | difference between consecutive timestamps above which they are 64 | considered to belong to different training sessions.} 65 | 66 | \item{correct_distances}{Logical. Should the distances be corrected 67 | for elevation? Default is \code{FALSE}.} 68 | 69 | \item{smooth_elevation_gain}{Logical. Should the elevation gain be 70 | smoothed before computing elevation gain? Default 71 | is \code{TRUE}.} 72 | 73 | \item{country}{ISO3 country code for downloading altitude data. If 74 | \code{NULL}, country is derived from longitude and latitude} 75 | 76 | \item{mask}{Logical. Passed on to 77 | \code{\link[raster]{getData}}. Should only the altitudes for 78 | the specified \code{country} be extracted (\code{TRUE}) or also 79 | those for the neighbouring countries (\code{FALSE})?} 80 | 81 | \item{from_distances}{Logical. Should the speeds be calculated from 82 | the distance recordings instead of taken from the speed 83 | recordings directly. Defaults to \code{TRUE} for \code{tcx} and 84 | Golden Cheetah's json files and to \code{FALSE} for \code{db3} 85 | files.} 86 | 87 | \item{speedunit}{Character string indicating the measurement unit 88 | of the speeds in the container file to be converted into meters 89 | per second. Default is \code{m_per_s} when \code{type} is 90 | \code{tcx} and \code{km_per_h} when \code{type} is \code{db3} 91 | or \code{json}. See Details.} 92 | 93 | \item{distanceunit}{Character string indicating the measurement 94 | unit of the distance in the container file to be converted into 95 | meters. Default is \code{m} when \code{type} is \code{tcx} and 96 | \code{km} when \code{type} is \code{db3} or \code{json}. See 97 | Details.} 98 | 99 | \item{sport}{What sport does \code{file} contain data from? Either 100 | \code{'cycling'}, \code{'running'}, \code{'swimming'} or 101 | \code{NULL} (default), in which case the sport is directly 102 | obtained from the \code{\link{readX}} extractors.} 103 | 104 | \item{lgap}{Time in seconds corresponding to the minimal sampling rate.} 105 | 106 | \item{lskip}{Time in seconds between the last observation before a small break 107 | and the first imputed speed or the last imputed speed and the first 108 | observation after a small break.} 109 | 110 | \item{m}{Number of imputed observations in each small break.} 111 | 112 | \item{silent}{Logical. Should warnings be generated if any of the 113 | sanity checks on the data are triggered?} 114 | } 115 | \value{ 116 | An object of class \code{\link{trackeRdata}}. 117 | } 118 | \description{ 119 | Read a GPS container file. 120 | } 121 | \details{ 122 | Available options for \code{speedunit} currently are 123 | \code{km_per_h}, \code{m_per_s}, \code{mi_per_h}, 124 | \code{ft_per_min} and \code{ft_per_s}. Available options for 125 | \code{distanceunit} currently are \code{km}, \code{m}, 126 | \code{mi} and \code{ft}. 127 | 128 | \code{read_container} try to identify the sport from the data in 129 | the container file. If that fails, then an attempt is made to guess 130 | the sport from keywords in the filename. If identification is not 131 | possible then an error is returned from 132 | \code{\link{trackeRdata}}. To avoid that error, and if the sport is 133 | known, append an appropriate keyword to the filename (e.g. 'ride', 134 | 'swim', 'run'). This should fix the error. 135 | } 136 | \examples{ 137 | filepath <- system.file("extdata/tcx", "2013-06-08-090442.TCX.gz", package = "trackeR") 138 | run <- read_container(filepath, type = "tcx", timezone = "GMT") 139 | } 140 | \seealso{ 141 | \code{\link{trackeRdata}}, \code{\link{readTCX}}, \code{\link{readDB3}}, \code{\link{readJSON}} 142 | } 143 | -------------------------------------------------------------------------------- /man/read_directory.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/reading.R, R/zzz_aliases.R 3 | \name{read_directory} 4 | \alias{read_directory} 5 | \alias{readDirectory} 6 | \title{Read all supported container files from a supplied directory} 7 | \usage{ 8 | read_directory( 9 | directory, 10 | aggregate = FALSE, 11 | table = "gps_data", 12 | timezone = "", 13 | session_threshold = 2, 14 | smooth_elevation_gain = TRUE, 15 | correct_distances = FALSE, 16 | country = NULL, 17 | mask = TRUE, 18 | from_distances = NULL, 19 | speedunit = list(tcx = "m_per_s", gpx = "km_per_h", db3 = "km_per_h", json = 20 | "km_per_h"), 21 | distanceunit = list(tcx = "m", gpx = "km", db3 = "km", json = "km"), 22 | sport = NULL, 23 | lgap = 30, 24 | lskip = 5, 25 | m = 11, 26 | silent = FALSE, 27 | parallel = FALSE, 28 | verbose = TRUE 29 | ) 30 | 31 | readDirectory( 32 | directory, 33 | aggregate = FALSE, 34 | table = "gps_data", 35 | timezone = "", 36 | session_threshold = 2, 37 | smooth_elevation_gain = TRUE, 38 | correct_distances = FALSE, 39 | country = NULL, 40 | mask = TRUE, 41 | from_distances = NULL, 42 | speedunit = list(tcx = "m_per_s", gpx = "km_per_h", db3 = "km_per_h", json = 43 | "km_per_h"), 44 | distanceunit = list(tcx = "m", gpx = "km", db3 = "km", json = "km"), 45 | sport = NULL, 46 | lgap = 30, 47 | lskip = 5, 48 | m = 11, 49 | silent = FALSE, 50 | parallel = FALSE, 51 | verbose = TRUE 52 | ) 53 | } 54 | \arguments{ 55 | \item{directory}{The path to the directory.} 56 | 57 | \item{aggregate}{Logical. Aggregate data from different files to 58 | the same session if observations are less then 59 | \code{session_threshold} hours apart? Alternatively, data from 60 | different files is stored in different sessions.} 61 | 62 | \item{table}{The name of the table in the database for db3 files.} 63 | 64 | \item{timezone}{The timezone of the observations as passed on to 65 | \code{\link[base]{as.POSIXct}}. Ignored for JSON files.} 66 | 67 | \item{session_threshold}{The threshold in hours for the time 68 | difference between consecutive timestamps above which they are 69 | considered to belong to different training sessions.} 70 | 71 | \item{smooth_elevation_gain}{Logical. Should the elevation gain be 72 | smoothed before computing elevation gain? Default 73 | is \code{TRUE}.} 74 | 75 | \item{correct_distances}{Logical. Should the distances be corrected 76 | for elevation? Default is \code{FALSE}.} 77 | 78 | \item{country}{ISO3 country code for downloading altitude data. If 79 | \code{NULL}, country is derived from longitude and latitude} 80 | 81 | \item{mask}{Logical. Passed on to 82 | \code{\link[raster]{getData}}. Should only the altitudes for 83 | the specified \code{country} be extracted (\code{TRUE}) or also 84 | those for the neighbouring countries (\code{FALSE})?} 85 | 86 | \item{from_distances}{Logical. Should the speeds be calculated from 87 | the distance recordings instead of taken from the speed 88 | recordings directly. Defaults to \code{TRUE} for tcx and Golden 89 | Cheetah's json files and to \code{FALSE} for db3 files.} 90 | 91 | \item{speedunit}{Character string indicating the measurement unit 92 | of the speeds in the container file to be converted into meters 93 | per second. Default is \code{m_per_s} for tcx files and 94 | \code{km_per_h} for db3 and Golden Cheetah's json files. See 95 | Details.} 96 | 97 | \item{distanceunit}{Character string indicating the measurement 98 | unit of the distance in the container file to be converted into 99 | meters. Default is \code{m} for tcx files and \code{km} for db3 100 | and Golden Cheetah's json files. See Details.} 101 | 102 | \item{sport}{What sport do the files in \code{directory} correspond 103 | to? Either \code{'cycling'}, \code{'running'}, 104 | \code{'swimming'} or \code{NULL} (default), in which case an 105 | attempt is made to extract the sport from each file in 106 | \code{directory}.} 107 | 108 | \item{lgap}{Time in seconds corresponding to the minimal sampling rate.} 109 | 110 | \item{lskip}{Time in seconds between the last observation before a small break 111 | and the first imputed speed or the last imputed speed and the first 112 | observation after a small break.} 113 | 114 | \item{m}{Number of imputed observations in each small break.} 115 | 116 | \item{silent}{Logical. Should warnings be generated if any of the 117 | sanity checks on the data are triggered?} 118 | 119 | \item{parallel}{Logical. Should reading be carried out in parallel? 120 | If \code{TRUE} reading is performed in parallel using the 121 | backend provided to \pkg{foreach}. Default is 122 | \code{FALSE}.} 123 | 124 | \item{verbose}{Logical. Should progress reports be printed?} 125 | } 126 | \value{ 127 | An object of class \code{\link{trackeRdata}}. 128 | } 129 | \description{ 130 | Read all supported container files from a supplied directory 131 | } 132 | \details{ 133 | Available options for \code{speedunit} currently are 134 | \code{km_per_h}, \code{m_per_s}, \code{mi_per_h}, 135 | \code{ft_per_min} and \code{ft_per_s}. Available options for 136 | \code{distanceunit} currently are \code{km}, \code{m}, 137 | \code{mi} and \code{ft}. 138 | 139 | If \code{aggregate = TRUE}, then if \code{sport = NULL} the 140 | sport in all sessions is determined by the first file read with 141 | a sport specification; else if \code{sport} is one of the other 142 | valid options it determines the sport for all sessions. 143 | } 144 | \examples{ 145 | \dontrun{ 146 | filepath <- system.file("extdata/gpx", package = "trackeR") 147 | gpx_files <- read_directory(filepath) 148 | } 149 | 150 | } 151 | \seealso{ 152 | \code{\link{trackeRdata}}, \code{\link{readTCX}}, \code{\link{readDB3}}, \code{\link{readJSON}} 153 | } 154 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | # trackeR 6 | 7 | [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/trackeR)](https://cran.r-project.org/package=trackeR) 8 | [![Coverage Status](https://coveralls.io/repos/github/trackerproject/trackeR/badge.svg?branch=master)](https://coveralls.io/github/trackerproject/trackeR?branch=master) 9 | [![R-CMD-check](https://github.com/trackerproject/trackeR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/trackerproject/trackeR/actions/workflows/R-CMD-check.yaml) 10 | [![Licence](https://img.shields.io/badge/licence-GPL--3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html) 11 | 12 | 13 | ### Description 14 | 15 | The purpose of this package is to provide infrastructure for handling 16 | running, cycling, and swimming data from GPS-enabled tracking devices. 17 | 18 | The formats that are currently supported for the training activity 19 | files are .tcx (Training Center XML), Strava .gpx, .db3 and [Golden 20 | Cheetah](http://goldencheetah.org) .json files. After extraction and 21 | appropriate manipulation of the training or competition attributes, 22 | the data are placed into session-based and unit-aware data objects of 23 | class trackeRdata (S3 class). The information in the resultant data 24 | objects can then be visualised, summarised, and analysed through 25 | corresponding flexible and extensible methods. 26 | 27 | ### Current capabilities 28 | 29 | Read: 30 | 31 | - Read data from .tcx, Strava .gpx, .db3 or [Golden Cheetah](http://goldencheetah.org) .json files. 32 | - Read all supported files in a specified directory. 33 | 34 | Sports supported: 35 | 36 | - Running 37 | - Cycling 38 | - Swimming 39 | 40 | Data processing: 41 | 42 | - Automatically identify sessions from timestamps. 43 | - Imputation of data to characterise times when the device is paused or remains stationary. 44 | - Correction of GPS-measured distances using elevation data. 45 | - Basic data cleaning capabilities e.g., no negative speeds or distances. 46 | - Specify and conveniently change units of measurement. 47 | - Organise data into session-based and unit-aware data objects of class trackeRdata. 48 | 49 | Analysis: 50 | 51 | - Session summaries: distance, duration, time moving, average speed/pace/heart 52 | rate/cadence/power (overall and moving), work to rest ratio, temperature. 53 | - Time spent exercising in user-supplied zones, e.g., heart rate zones or speed zones. 54 | - Work capacity above critical power (W', W prime) 55 | - Distribution profiles: time spent exercising above thresholds of training attributes. 56 | - Concentration profiles: negative derivatives of distribution profiles. 57 | - Functional principal components analysis of distribution and concentration profiles. 58 | 59 | Visualisation: 60 | 61 | - Plot session progression in, e.g., pace, heart rate, etc. 62 | - Plot route covered during session on static and interactive maps from various providers. 63 | - Plot session summary statistics. 64 | - Plot date time of sessions in timeline plots. 65 | - Plot time spent exercising in zones. 66 | - Plot distribution/concentration profiles. 67 | - Plot principal components of distribution/concentration profiles. 68 | - Ridgeline (or joy) plots for distribution/concentration profiles. 69 | 70 | ### Installation 71 | 72 | Install the released version from CRAN: 73 | 74 | ```{r, eval = FALSE} 75 | install.packages("trackeR") 76 | ``` 77 | 78 | Or the development version from github: 79 | 80 | ```{r, eval = FALSE} 81 | # install.packages("devtools") 82 | devtools::install_github("trackerproject/trackeR") 83 | ``` 84 | 85 | 86 | ### Example 87 | 88 | Plot workout data 89 | ```{r, plots, message = FALSE, fig.height = 6.5} 90 | data(runs, package = "trackeR") 91 | plot(runs, session = 1:5, what = c("speed", "pace", "altitude")) 92 | ``` 93 | 94 | Change the units 95 | ```{r, plots_new, message = FALSE, fig.height = 6.5} 96 | data(runs, package = "trackeR") 97 | runs0 <- change_units(runs, 98 | variable = c("speed", "altitude"), 99 | unit = c("km_per_h", "ft"), 100 | sport = c("running", "running")) 101 | plot(runs0, session = 1:5, what = c("speed", "pace", "altitude")) 102 | ``` 103 | 104 | Summarise sessions 105 | ```{r, summary, message = FALSE, fig.height = 6.5} 106 | library("trackeR") 107 | runs_summary <- summary(runs) 108 | plot(runs_summary, group = c("total", "moving"), 109 | what = c("avgSpeed", "distance", "duration", "avgHeartRate")) 110 | ``` 111 | 112 | Generate distribution and concentration profiles 113 | 114 | ```{r, cprofile, fig.width = 9} 115 | runsT <- threshold(runs) 116 | dp_runs <- distribution_profile(runsT, what = c("speed", "heart_rate")) 117 | dp_runs_smooth <- smoother(dp_runs) 118 | cp_runs <- concentration_profile(dp_runs_smooth) 119 | plot(cp_runs, multiple = TRUE, smooth = FALSE) 120 | ``` 121 | 122 | A ridgeline plot of the concentration profiles 123 | ```{r, cprofile-ridges, warning = FALSE, fig.width = 9} 124 | ridges(cp_runs, what = "speed") 125 | ``` 126 | 127 | ```{r, cprofile-ridges-hr, warning = FALSE, fig.width = 9} 128 | ridges(cp_runs, what = "heart_rate") 129 | ``` 130 | 131 | Explore concentration profiles for speed, e.g., via functional principal 132 | components analysis (PCA) 133 | 134 | ```{r, funPCA, fig.width = 7, fig.height = 7} 135 | ## fit functional PCA 136 | cp_PCA <- funPCA(cp_runs, what = "speed", nharm = 4) 137 | 138 | ## pick first 2 harmonics/principal components 139 | round(cp_PCA$varprop, 2) 140 | 141 | ## plot harmonics 142 | plot(cp_PCA, harm = 1:2) 143 | ``` 144 | 145 | ```{r, scores} 146 | ## plot scores vs summary statistics 147 | scores_SP <- data.frame(cp_PCA$scores) 148 | names(scores_SP) <- paste0("speed_pc", 1:4) 149 | d <- cbind(runs_summary, scores_SP) 150 | 151 | library("ggplot2") 152 | ## pc1 ~ session duration (moving) 153 | ggplot(d) + geom_point(aes(x = as.numeric(durationMoving), y = speed_pc1)) + theme_bw() 154 | ## pc2 ~ avg speed (moving) 155 | ggplot(d) + geom_point(aes(x = avgSpeedMoving, y = speed_pc2)) + theme_bw() 156 | ``` 157 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # trackeR 2 | 3 | [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/trackeR)](https://cran.r-project.org/package=trackeR) 4 | [![Coverage 5 | Status](https://coveralls.io/repos/github/trackerproject/trackeR/badge.svg?branch=master)](https://coveralls.io/github/trackerproject/trackeR?branch=master) 6 | [![R-CMD-check](https://github.com/trackerproject/trackeR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/trackerproject/trackeR/actions/workflows/R-CMD-check.yaml) 7 | [![Licence](https://img.shields.io/badge/licence-GPL--3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html) 8 | 9 | ### Description 10 | 11 | The purpose of this package is to provide infrastructure for handling 12 | running, cycling, and swimming data from GPS-enabled tracking devices. 13 | 14 | The formats that are currently supported for the training activity files 15 | are .tcx (Training Center XML), Strava .gpx, .db3 and [Golden 16 | Cheetah](http://goldencheetah.org) .json files. After extraction and 17 | appropriate manipulation of the training or competition attributes, the 18 | data are placed into session-based and unit-aware data objects of class 19 | trackeRdata (S3 class). The information in the resultant data objects 20 | can then be visualised, summarised, and analysed through corresponding 21 | flexible and extensible methods. 22 | 23 | ### Current capabilities 24 | 25 | Read: 26 | 27 | - Read data from .tcx, Strava .gpx, .db3 or [Golden 28 | Cheetah](http://goldencheetah.org) .json files. 29 | - Read all supported files in a specified directory. 30 | 31 | Sports supported: 32 | 33 | - Running 34 | - Cycling 35 | - Swimming 36 | 37 | Data processing: 38 | 39 | - Automatically identify sessions from timestamps. 40 | - Imputation of data to characterise times when the device is paused or 41 | remains stationary. 42 | - Correction of GPS-measured distances using elevation data. 43 | - Basic data cleaning capabilities e.g., no negative speeds or 44 | distances. 45 | - Specify and conveniently change units of measurement. 46 | - Organise data into session-based and unit-aware data objects of class 47 | trackeRdata. 48 | 49 | Analysis: 50 | 51 | - Session summaries: distance, duration, time moving, average 52 | speed/pace/heart rate/cadence/power (overall and moving), work to rest 53 | ratio, temperature. 54 | - Time spent exercising in user-supplied zones, e.g., heart rate zones 55 | or speed zones. 56 | - Work capacity above critical power (W’, W prime) 57 | - Distribution profiles: time spent exercising above thresholds of 58 | training attributes. 59 | - Concentration profiles: negative derivatives of distribution profiles. 60 | - Functional principal components analysis of distribution and 61 | concentration profiles. 62 | 63 | Visualisation: 64 | 65 | - Plot session progression in, e.g., pace, heart rate, etc. 66 | - Plot route covered during session on static and interactive maps from 67 | various providers. 68 | - Plot session summary statistics. 69 | - Plot date time of sessions in timeline plots. 70 | - Plot time spent exercising in zones. 71 | - Plot distribution/concentration profiles. 72 | - Plot principal components of distribution/concentration profiles. 73 | - Ridgeline (or joy) plots for distribution/concentration profiles. 74 | 75 | ### Installation 76 | 77 | Install the released version from CRAN: 78 | 79 | install.packages("trackeR") 80 | 81 | Or the development version from github: 82 | 83 | # install.packages("devtools") 84 | devtools::install_github("trackerproject/trackeR") 85 | 86 | ### Example 87 | 88 | Plot workout data 89 | 90 | data(runs, package = "trackeR") 91 | plot(runs, session = 1:5, what = c("speed", "pace", "altitude")) 92 | 93 | ![](README_files/figure-markdown_strict/plots-1.png) 94 | 95 | Change the units 96 | 97 | data(runs, package = "trackeR") 98 | runs0 <- change_units(runs, 99 | variable = c("speed", "altitude"), 100 | unit = c("km_per_h", "ft"), 101 | sport = c("running", "running")) 102 | plot(runs0, session = 1:5, what = c("speed", "pace", "altitude")) 103 | 104 | ![](README_files/figure-markdown_strict/plots_new-1.png) 105 | 106 | Summarise sessions 107 | 108 | library("trackeR") 109 | runs_summary <- summary(runs) 110 | plot(runs_summary, group = c("total", "moving"), 111 | what = c("avgSpeed", "distance", "duration", "avgHeartRate")) 112 | 113 | ![](README_files/figure-markdown_strict/summary-1.png) 114 | 115 | Generate distribution and concentration profiles 116 | 117 | runsT <- threshold(runs) 118 | dp_runs <- distribution_profile(runsT, what = c("speed", "heart_rate")) 119 | dp_runs_smooth <- smoother(dp_runs) 120 | cp_runs <- concentration_profile(dp_runs_smooth) 121 | plot(cp_runs, multiple = TRUE, smooth = FALSE) 122 | 123 | ![](README_files/figure-markdown_strict/cprofile-1.png) 124 | 125 | A ridgeline plot of the concentration profiles 126 | 127 | ridges(cp_runs, what = "speed") 128 | 129 | ![](README_files/figure-markdown_strict/cprofile-ridges-1.png) 130 | 131 | ridges(cp_runs, what = "heart_rate") 132 | 133 | ![](README_files/figure-markdown_strict/cprofile-ridges-hr-1.png) 134 | 135 | Explore concentration profiles for speed, e.g., via functional principal 136 | components analysis (PCA) 137 | 138 | ## fit functional PCA 139 | cp_PCA <- funPCA(cp_runs, what = "speed", nharm = 4) 140 | 141 | ## pick first 2 harmonics/principal components 142 | round(cp_PCA$varprop, 2) 143 | 144 | ## [1] 0.66 0.25 0.06 0.02 145 | 146 | ## plot harmonics 147 | plot(cp_PCA, harm = 1:2) 148 | 149 | ![](README_files/figure-markdown_strict/funPCA-1.png) 150 | 151 | ## plot scores vs summary statistics 152 | scores_SP <- data.frame(cp_PCA$scores) 153 | names(scores_SP) <- paste0("speed_pc", 1:4) 154 | d <- cbind(runs_summary, scores_SP) 155 | 156 | library("ggplot2") 157 | ## pc1 ~ session duration (moving) 158 | ggplot(d) + geom_point(aes(x = as.numeric(durationMoving), y = speed_pc1)) + theme_bw() 159 | 160 | ![](README_files/figure-markdown_strict/scores-1.png) 161 | 162 | ## pc2 ~ avg speed (moving) 163 | ggplot(d) + geom_point(aes(x = avgSpeedMoving, y = speed_pc2)) + theme_bw() 164 | 165 | ![](README_files/figure-markdown_strict/scores-2.png) 166 | -------------------------------------------------------------------------------- /man/conversions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/units.R 3 | \name{conversions} 4 | \alias{conversions} 5 | \alias{m2km} 6 | \alias{km2m} 7 | \alias{m2ft} 8 | \alias{ft2m} 9 | \alias{m2mi} 10 | \alias{mi2m} 11 | \alias{km2ft} 12 | \alias{ft2km} 13 | \alias{km2mi} 14 | \alias{mi2km} 15 | \alias{ft2mi} 16 | \alias{mi2ft} 17 | \alias{m2m} 18 | \alias{km2km} 19 | \alias{ft2ft} 20 | \alias{mi2mi} 21 | \alias{s2min} 22 | \alias{min2s} 23 | \alias{s2h} 24 | \alias{h2s} 25 | \alias{min2h} 26 | \alias{h2min} 27 | \alias{h2h} 28 | \alias{min2min} 29 | \alias{s2s} 30 | \alias{degree2degree} 31 | \alias{m_per_s2km_per_h} 32 | \alias{km_per_h2m_per_s} 33 | \alias{m_per_s2ft_per_min} 34 | \alias{ft_per_min2m_per_s} 35 | \alias{m_per_s2ft_per_s} 36 | \alias{ft_per_s2m_per_s} 37 | \alias{m_per_s2mi_per_h} 38 | \alias{mi_per_h2m_per_s} 39 | \alias{m_per_s2km_per_min} 40 | \alias{km_per_min2m_per_s} 41 | \alias{m_per_s2mi_per_min} 42 | \alias{mi_per_min2m_per_s} 43 | \alias{km_per_h2ft_per_min} 44 | \alias{ft_per_min2km_per_h} 45 | \alias{km_per_h2ft_per_s} 46 | \alias{ft_per_s2km_per_h} 47 | \alias{km_per_h2mi_per_h} 48 | \alias{mi_per_h2km_per_h} 49 | \alias{km_per_h2km_per_min} 50 | \alias{km_per_min2km_per_h} 51 | \alias{km_per_h2mi_per_min} 52 | \alias{mi_per_min2km_per_h} 53 | \alias{ft_per_min2ft_per_s} 54 | \alias{ft_per_s2ft_per_min} 55 | \alias{ft_per_min2mi_per_h} 56 | \alias{mi_per_h2ft_per_min} 57 | \alias{ft_per_min2km_per_min} 58 | \alias{km_per_min2ft_per_min} 59 | \alias{ft_per_min2mi_per_min} 60 | \alias{mi_per_min2ft_per_min} 61 | \alias{ft_per_s2mi_per_h} 62 | \alias{mi_per_h2ft_per_s} 63 | \alias{ft_per_s2km_per_min} 64 | \alias{km_per_min2ft_per_s} 65 | \alias{ft_per_s2mi_per_min} 66 | \alias{mi_per_min2ft_per_s} 67 | \alias{mi_per_h2km_per_min} 68 | \alias{km_per_min2mi_per_h} 69 | \alias{mi_per_h2mi_per_min} 70 | \alias{mi_per_min2mi_per_h} 71 | \alias{km_per_min2mi_per_min} 72 | \alias{mi_per_min2km_per_min} 73 | \alias{m_per_s2m_per_s} 74 | \alias{km_per_h2km_per_h} 75 | \alias{ft_per_min2ft_per_min} 76 | \alias{ft_per_s2ft_per_s} 77 | \alias{mi_per_h2mi_per_h} 78 | \alias{km_per_min2km_per_min} 79 | \alias{mi_per_min2mi_per_min} 80 | \alias{m_per_s2m_per_min} 81 | \alias{m_per_min2m_per_s} 82 | \alias{m_per_min2m_per_min} 83 | \alias{bpm2bpm} 84 | \alias{s_per_m2min_per_km} 85 | \alias{min_per_km2s_per_m} 86 | \alias{s_per_m2min_per_mi} 87 | \alias{min_per_mi2s_per_m} 88 | \alias{min_per_km2min_per_mi} 89 | \alias{min_per_mi2min_per_km} 90 | \alias{min_per_ft2min_per_km} 91 | \alias{min_per_ft2min_per_mi} 92 | \alias{s_per_m2s_per_m} 93 | \alias{min_per_km2min_per_km} 94 | \alias{min_per_mi2min_per_mi} 95 | \alias{h_per_km2min_per_km} 96 | \alias{h_per_km2min_per_mi} 97 | \alias{h_per_mi2min_per_km} 98 | \alias{h_per_mi2min_per_mi} 99 | \alias{W2kW} 100 | \alias{kW2W} 101 | \alias{W2W} 102 | \alias{kW2kW} 103 | \alias{steps_per_min2steps_per_min} 104 | \alias{rev_per_min2rev_per_min} 105 | \alias{steps_per_min2rev_per_min} 106 | \alias{rev_per_min2steps_per_min} 107 | \alias{C2F} 108 | \alias{C2C} 109 | \alias{F2F} 110 | \alias{F2C} 111 | \title{Auxiliary conversion functions} 112 | \usage{ 113 | m2km(variable) 114 | 115 | km2m(variable) 116 | 117 | m2ft(variable) 118 | 119 | ft2m(variable) 120 | 121 | m2mi(variable) 122 | 123 | mi2m(variable) 124 | 125 | km2ft(variable) 126 | 127 | ft2km(variable) 128 | 129 | km2mi(variable) 130 | 131 | mi2km(variable) 132 | 133 | ft2mi(variable) 134 | 135 | mi2ft(variable) 136 | 137 | m2m(variable) 138 | 139 | km2km(variable) 140 | 141 | ft2ft(variable) 142 | 143 | mi2mi(variable) 144 | 145 | s2min(variable) 146 | 147 | min2s(variable) 148 | 149 | s2h(variable) 150 | 151 | h2s(variable) 152 | 153 | min2h(variable) 154 | 155 | h2min(variable) 156 | 157 | h2h(variable) 158 | 159 | min2min(variable) 160 | 161 | s2s(variable) 162 | 163 | min2min(variable) 164 | 165 | h2h(variable) 166 | 167 | degree2degree(variable) 168 | 169 | m_per_s2km_per_h(variable) 170 | 171 | km_per_h2m_per_s(variable) 172 | 173 | m_per_s2ft_per_min(variable) 174 | 175 | ft_per_min2m_per_s(variable) 176 | 177 | m_per_s2ft_per_s(variable) 178 | 179 | ft_per_s2m_per_s(variable) 180 | 181 | m_per_s2mi_per_h(variable) 182 | 183 | mi_per_h2m_per_s(variable) 184 | 185 | m_per_s2km_per_min(variable) 186 | 187 | km_per_min2m_per_s(variable) 188 | 189 | m_per_s2mi_per_min(variable) 190 | 191 | mi_per_min2m_per_s(variable) 192 | 193 | km_per_h2ft_per_min(variable) 194 | 195 | ft_per_min2km_per_h(variable) 196 | 197 | km_per_h2ft_per_s(variable) 198 | 199 | ft_per_s2km_per_h(variable) 200 | 201 | km_per_h2mi_per_h(variable) 202 | 203 | mi_per_h2km_per_h(variable) 204 | 205 | km_per_h2km_per_min(variable) 206 | 207 | km_per_min2km_per_h(variable) 208 | 209 | km_per_h2mi_per_min(variable) 210 | 211 | mi_per_min2km_per_h(variable) 212 | 213 | ft_per_min2ft_per_s(variable) 214 | 215 | ft_per_s2ft_per_min(variable) 216 | 217 | ft_per_min2mi_per_h(variable) 218 | 219 | mi_per_h2ft_per_min(variable) 220 | 221 | ft_per_min2km_per_min(variable) 222 | 223 | km_per_min2ft_per_min(variable) 224 | 225 | ft_per_min2mi_per_min(variable) 226 | 227 | mi_per_min2ft_per_min(variable) 228 | 229 | ft_per_s2mi_per_h(variable) 230 | 231 | mi_per_h2ft_per_s(variable) 232 | 233 | ft_per_s2km_per_min(variable) 234 | 235 | km_per_min2ft_per_s(variable) 236 | 237 | ft_per_s2mi_per_min(variable) 238 | 239 | mi_per_min2ft_per_s(variable) 240 | 241 | mi_per_h2km_per_min(variable) 242 | 243 | km_per_min2mi_per_h(variable) 244 | 245 | mi_per_h2mi_per_min(variable) 246 | 247 | mi_per_min2mi_per_h(variable) 248 | 249 | km_per_min2mi_per_min(variable) 250 | 251 | mi_per_min2km_per_min(variable) 252 | 253 | m_per_s2m_per_s(variable) 254 | 255 | km_per_h2km_per_h(variable) 256 | 257 | ft_per_min2ft_per_min(variable) 258 | 259 | ft_per_s2ft_per_s(variable) 260 | 261 | mi_per_h2mi_per_h(variable) 262 | 263 | km_per_min2km_per_min(variable) 264 | 265 | mi_per_min2mi_per_min(variable) 266 | 267 | m_per_s2m_per_min(variable) 268 | 269 | m_per_min2m_per_s(variable) 270 | 271 | m_per_min2m_per_min(variable) 272 | 273 | bpm2bpm(variable) 274 | 275 | s_per_m2min_per_km(variable) 276 | 277 | min_per_km2s_per_m(variable) 278 | 279 | s_per_m2min_per_mi(variable) 280 | 281 | min_per_mi2s_per_m(variable) 282 | 283 | min_per_km2min_per_mi(variable) 284 | 285 | min_per_mi2min_per_km(variable) 286 | 287 | min_per_ft2min_per_km(variable) 288 | 289 | min_per_ft2min_per_mi(variable) 290 | 291 | s_per_m2s_per_m(variable) 292 | 293 | min_per_km2min_per_km(variable) 294 | 295 | min_per_mi2min_per_mi(variable) 296 | 297 | h_per_km2min_per_km(variable) 298 | 299 | h_per_km2min_per_mi(variable) 300 | 301 | h_per_mi2min_per_km(variable) 302 | 303 | h_per_mi2min_per_mi(variable) 304 | 305 | W2kW(variable) 306 | 307 | kW2W(variable) 308 | 309 | W2W(variable) 310 | 311 | kW2kW(variable) 312 | 313 | steps_per_min2steps_per_min(variable) 314 | 315 | rev_per_min2rev_per_min(variable) 316 | 317 | steps_per_min2rev_per_min(variable) 318 | 319 | rev_per_min2steps_per_min(variable) 320 | 321 | C2F(variable) 322 | 323 | C2C(variable) 324 | 325 | F2F(variable) 326 | 327 | F2C(variable) 328 | } 329 | \arguments{ 330 | \item{variable}{Variable to be converted.} 331 | } 332 | \description{ 333 | Conversion functions for distance, duration, speed, pace, power, 334 | cadence and temperature. 335 | } 336 | -------------------------------------------------------------------------------- /R/thresholds.R: -------------------------------------------------------------------------------- 1 | #' Thresholding for variables in \code{trackeRdata} objects 2 | #' 3 | #' @param object An object of class \code{\link{trackeRdata}}. 4 | #' @param variable A vector containing the names of the variables to 5 | #' which thresholding is applied. See Details. 6 | #' @param lower A vector containing the corresponding lower 7 | #' thresholds. See Details. 8 | #' @param upper A vector containing the corresponding upper 9 | #' thresholds. See Details. 10 | #' @param sport A vector of sports (amongst \code{'cycling'}, 11 | #' \code{'running'}, \code{'swimming'}) with each element 12 | #' corresponding to \code{variable}, \code{lower} and \code{upper} 13 | #' @param trace Should a progress report be printed? Default is \code{FALSE} 14 | #' @param ... Currently not used. 15 | #' @details 16 | #' 17 | #' \code{lower} and \code{upper} are always understood as referring to 18 | #' the units of the \code{object}. 19 | #' 20 | #' If the arguments \code{variable}, \code{lower}, and \code{upper} 21 | #' are all unspecified, the following default thresholds are employed 22 | #' \itemize{ 23 | #' \item latitude [-90, 90] degrees 24 | #' \item longitude [-180, 180] degrees 25 | #' \item altitude [-500, 9000] m 26 | #' \item distance [0, Inf] meters 27 | #' \item cadence_running [0, Inf] steps per min 28 | #' \item cadence_cycling [0, Inf] revolutions per min 29 | #' \item speed [0, Inf] meters 30 | #' \item heart rate [0, 250] bpm 31 | #' \item power [0, Inf] W 32 | #' \item pace [0, Inf] min per km 33 | #' \item duration [0, Inf] seconds 34 | #' \item temperature [-20, 60] C 35 | #' } 36 | #' after they have been transformed to the units of the \code{object} 37 | #' 38 | #' The thresholds for speed differ across sports: for running they are 39 | #' [0, 12.5] meters per second, for cycling [0, 100] meters per second 40 | #' and for swimming [0, 5] meters per second. 41 | #' 42 | #' 43 | #' @examples 44 | #' \dontrun{ 45 | #' data('runs', package = 'trackeR') 46 | #' plot(runs, session = 4, what = 'speed', threshold = FALSE) 47 | #' runsT <- threshold(runs, variable = 'speed', lower = 0, upper = 12.5, sport = "running") 48 | #' plot(runsT, session = 4, what = 'speed', threshold = FALSE) 49 | #' } 50 | #' @export 51 | threshold.trackeRdata <- function(object, 52 | variable, 53 | lower, 54 | upper, 55 | sport, 56 | trace = FALSE, 57 | ...) { 58 | 59 | sports <- get_sport(object) 60 | units <- get_units(object) 61 | operations <- get_operations(object) 62 | 63 | ## if variable is NULL, just update attribute, leave data unchanged 64 | if (!missing(variable) && is.null(variable)) { 65 | operations <- get_operations(object) 66 | operations$threshold <- NULL 67 | attr(object, "operations") <- operations 68 | return(object) 69 | } 70 | 71 | no_variable <- missing(variable) 72 | no_unit <- missing(variable) 73 | no_sport <- missing(sport) 74 | 75 | ## Generate default thresholds 76 | thresholds <- generate_thresholds() 77 | ## Change default threshold units to the units of object 78 | thresholds <- change_units(thresholds, variable = units$variable, unit = units$unit, sport = units$sport) 79 | thresholds$changed <- FALSE 80 | 81 | if (!(no_sport & no_unit & no_variable)) { 82 | ## Assuming that lower and upper are supplied in the units of object 83 | ## This will also check if variable, lower, upper and sport have the right lengths 84 | thresholds_new <- generate_thresholds(variable, lower, upper, sport) 85 | thresholds_new$changed <- FALSE 86 | p <- length(variable) 87 | for (j in seq.int(p)) { 88 | ind <- thresholds_new$variable == variable[j] & thresholds_new$sport == sport[j] 89 | ## Set changed limits to their values 90 | thresholds[ind, ] <- thresholds_new[ind, ] 91 | thresholds[ind, "changed"] <- TRUE 92 | } 93 | } 94 | else { 95 | ## Assume that all are changed 96 | thresholds$changed <- TRUE 97 | } 98 | 99 | ## Change thresholds 100 | for (sp in unique(sports)) { 101 | th <- subset(thresholds, sport == sp) 102 | for (k in which(th$changed)) { 103 | va <- th$variable[k] 104 | ## trackeRdata objects do not carry duration so skip 105 | if (va == "duration") { 106 | next 107 | } 108 | if (isTRUE(trace)) { 109 | cat("Thresholding", va, "for", paste0(sp, "...")) 110 | } 111 | for (sess in which(sports == sp)) { 112 | inds_lower <- object[[sess]][, va] < th$lower[k] 113 | inds_upper <- object[[sess]][, va] > th$upper[k] 114 | object[[sess]][inds_lower, va] <- NA 115 | object[[sess]][inds_upper, va] <- NA 116 | } 117 | if (isTRUE(trace)) { 118 | cat(" Done!\n") 119 | } 120 | } 121 | } 122 | 123 | 124 | thresholds$changed <- NULL 125 | 126 | ## update attribute 127 | operations$threshold <- thresholds 128 | attr(object, "operations") <- operations 129 | 130 | return(object) 131 | } 132 | 133 | #' Change the units of the variables in an \code{trackeRthresholds} object 134 | #' 135 | #' @param object An object of class \code{trackeRthresholds}. 136 | #' @inheritParams change_units 137 | #' @export 138 | change_units.trackeRthresholds <- function(object, 139 | variable, 140 | unit, 141 | sport, 142 | ...) { 143 | no_variable <- missing(variable) 144 | no_unit <- missing(unit) 145 | no_sport <- missing(sport) 146 | 147 | if (no_sport & no_unit & no_variable) { 148 | return(object) 149 | } 150 | else { 151 | p <- length(sport) 152 | if (length(unit) == p & length(variable) == p) { 153 | inputs <- data.frame(sport = sport, variable = variable, unit = unit, stringsAsFactors = FALSE) 154 | inds <- match(paste(inputs$sport, inputs$variable, sep = "-"), 155 | paste(object$sport, object$variable, sep = "-"), 156 | nomatch = 0) 157 | object$new_unit <- object$unit 158 | ## If variable/sport/units combinations do not exist then the object is returned 159 | if (all(inds == 0)) { 160 | stop("some of the supplied combinations of sport and variable do not exist.") 161 | } 162 | 163 | object$new_unit[inds] <- inputs$unit 164 | object$fun <- paste(object$unit, object$new_unit, sep = "2") 165 | 166 | ## Check for crappy units is inherent below 167 | for (i in seq.int(nrow(object))) { 168 | convert <- match.fun(object$fun[i]) 169 | object[i, "lower"] <- convert(object[i, "lower"]) 170 | object[i, "upper"] <- convert(object[i, "upper"]) 171 | } 172 | object$unit <- object$new_unit 173 | object$fun <- object$new_unit <- NULL 174 | return(object) 175 | } 176 | else { 177 | stop("variable, unit and sport should have the same length.") 178 | } 179 | } 180 | } 181 | --------------------------------------------------------------------------------