Learn R Programming

elpatron (version 0.0.4)

clean_bikedata: Clean raw cycling device data.

Description

These functions implement a consistent and predictable column structure for incoming cycling device data. This should permit, where necessary, batch operations on various different file formats. See below for details of this structure.

Usage

clean_bikedata(data, ...)

Arguments

data
data.frame to be "cleaned".
...
arguments to be passed down to select.

Value

a tbl_df with the column structure as described above, with a "start_time" attribute appended where available.NOTE: don't run this because valgrind complains about the FIT SDK src code.

Clean structure

In general, fields should be named as "field.units", where the field is generally written in full. Time derivatives should be adjacent to their "parent" (e.g. distance, speed; work, power). If data for any of these columns are missing the column should be included, but filled with NAs. The SI unit system should be adhered to.

Details

Note that these functions do not retain any of the original data columns. If extra columns want to be retained, extra arguments can be passed down to select via ...

If any required columns are missing in the original data, those columns of the specification (below) that depend on them will still be returned, but filled with NAs.

When imported with import_ride, the returned data is given a file extension attribute. This attribute is the basis for method dispatch here.

Examples

Run this code
## Not run: 
# ride_file <- system.file("extdata/lufbra.fit", package = "elpatron")
# 
# parsed_ride <- import_ride(ride_file, make_laps = TRUE)
# 
# ## Simple cleaning:
# clean_bikedata(parsed_ride)
# 
# ## Keep the lap column:
# clean_bikedata(parsed_ride, lap)
# 
# ## We can also make use of dplyr's select_helpers
# ## (see ?dplyr::select_helpers)
# 
# library(dplyr, warn.conflicts = FALSE)
# clean_bikedata(parsed_ride, lap, contains("torque"))
# 
# ## Trying to hold on to non-existent fields won't throw errors.
# clean_bikedata(parsed_ride, lap, contains("epo_concentration"))
# ## End(Not run)

Run the code above in your browser using DataLab