read_workouts: Read the workout files, and wrangle and organize them into...

Description Usage Arguments Details Value References See Also Examples

View source: R/GoldenCheetahOpenData-package.R

Description

Read the workout files, and wrangle and organize them into lists of trackeR::trackeRdata objects for further processing into the trackeR R package.

Usage

1
2
## S3 method for class 'gcod_db'
read_workouts(object, verbose = FALSE, clean_db = TRUE, write_rds = TRUE, ...)

Arguments

object

an object of class gcod_db, as produced from download_workouts() or extract_workouts().

verbose

logical determining whether progress information should be printed. Default is FALSE.

clean_db

logical determining whether the workout sub-directories should be deleted after processing. Default is TRUE.

write_rds

logical determining whether the processed trackeRdata objects should be written in the workout archive directory. Default is TRUE.

...

other arguments to be passed to extract_workouts().

Details

If any of local_perspective(object)$extracted is FALSE, then the workout files are extracted automatically using extract_workouts() with overwirte = FALSE and clean_up = FALSE.

It is assumed that the filename for each workout corresponds to the timestamp where the first observation is made for the session. Timestamps are in UTC.

If the number of workout files in the archive of a particular athlete ID does not match the number of workouts recorded in the json files within that archive, then the workout files for the ID are not read.

Value

A list of trackeR::trackeRdata objects.

References

Frick, H., Kosmidis, I. (2017). trackeR: Infrastructure for Running and Cycling Data from GPS-Enabled Tracking Devices in R. Journal of Statistical Software, 82(7), 1–29. doi:10.18637/jss.v082.i07

See Also

trackeR::trackeRdata() extract_workouts()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Get the two IDs starting with "000e" and "000d" and concatenate
## them into a single `gcod_db` object
ids000 <- lapply(c("000e", "000d"), function(x) get_athlete_ids(prefix = x))
ids000 <- c(ids000[[1]], ids000[[2]])

## Download the workout archives in tempdir()
ids000 <- download_workouts(ids000, verbose = TRUE, overwrite = TRUE)

## Read the workouts. This will create a list of two `trackeRdata`
## objects with 2 and 56 workouts
library("trackeR")
w000 <- read_workouts(ids000, clean_db = TRUE, verbose = TRUE)

## Now we can use methods from the trackeR R package
## Plot the workouts
plot(w000[[1]], what = "speed")
plot(w000[[2]], session = 1:5, what = c("speed", "heart_rate"))
## Compute concentration profiles for speed and power
cp <- concentration_profile(w000[[2]], what = c("speed", "power"))
plot(cp, multiple = TRUE)
## Get summaries for speed, power and work-to-rest ration
plot(summary(w000[[2]]), what = c("avgSpeed", "avgPower", "wrRatio"))

ikosmidis/GoldenCheetahOpenData documentation built on June 3, 2020, 9:25 a.m.