Learn R Programming

elpatron (version 0.0.4)

import_ride: Ride file parsing

Description

The generic import_ride dispatches methods based on the file extension of file_path. See Details for currently supported file formats. The default method (i.e. for unsupported formats) will raise an error.

Usage

import_ride(file_path, ...)
"import_ride"(file_path, raw = FALSE, make_laps = TRUE, ...)
"import_ride"(file_path, ...)
"import_ride"(file_path, make_laps = TRUE, ...)
"import_ride"(file_path, ...)
"import_ride"(file_path, ..., .python_exec = "python2")

Arguments

file_path
character string; path to the file to be read. Can be absolute or relative.
...
further arguments passed to or from other methods.
raw
logical; if TRUE all data retrieved from the fit file is returned as a list. raw = FALSE (default) will just return "records", which are generally what's expected/of interest.
make_laps
logical; append a lap column to the data (if available)?
.python_exec
character; path to a python executable. E.g. Sys.which("python"). The script was developed with python v2.7.11.

Value

With very few exceptions, these functions return data as a tbl_df, with the additional attribute "file_ext".

Notes

Garmin Fit files return positional coordinates in units of semicircles. These are converted to degrees by default (if raw = FALSE). The present implementation does not correctly parse enhanced fields, so these are discarded; not that these are of interest for most human-powered activities!

Acknowledgements

Fit files are parsed using code from the ANT+ FIT SDK. This code was ported to Rcpp and kindly contributed by Alex Cooper XML file formats are parsed using the pugixml C++ library. SRM parsing code was adapted from the code in the Golden Cheetah repository (which can be found here). All third-party licenses can be found in system.file("licenses", package = "elpatron").

Details

These functions will do very little with the parsed data by default. This is to allow for more flexibility, but can cause headaches for batch analysing files of mixed formats (see clean_bikedata for a solution).

Timestamps are converted to POSIXct when available.

Currently supported formats are:

  • pwx: Training Peaks pwx files (an XML format).
  • fit: Garmin fit files (a binary format).
  • tcx: Garmin training center files (an XML format).
  • gpx: GPS Exchange Format (a lame XML format).
  • srm: SRM power control files (a binary format).

Tabular data are always returned as dplyr tbl objects. This ensures clean printing and makes data easier to work with.

The method for SRM power control files uses python code. Hence import_ride.srm will raise an error if the python executable (given in the argument .python_exec) is not found on the system path. The method will also make use of the readr package if it is available (advised). Note the python script was developed with python version 2.7.11.

See Also

clean_bikedata for creating consistent output from these functions.

Examples

Run this code
## Not run: 
# ride_files <- list.files(
#   system.file("extdata", package = "elpatron"),
#   full.names = TRUE)
# 
# (f <- sample(ride_files, 1))
# import_ride(f)
# 
# ## If you want all data from the .fit format...
# f <- grep("fit$", ride_files, value = TRUE)
# import_ride(f, raw = TRUE)
# ## End(Not run)

Run the code above in your browser using DataLab