Description Usage Arguments Value Examples
Decode a FIT file
1 | read_fit(file_path)
|
file_path |
string; path to the FIT file to be read. |
decoded data messages from the FIT file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ## An example of generating a table of record messages
## from the file provided with this package:
fp <- system.file("extdata/example.fit", package = "fitdc")
data_mesgs <- read_fit(fp)
## Filter out the record messages:
is_record <- function(mesg) mesg$name == "record"
records <- Filter(is_record, data_mesgs)
format_record <- function(record) {
out <- record$fields
names(out) <- paste(names(out), record$units, sep = ".")
out
}
records <- lapply(records, format_record)
## Some records have missing fields:
colnames_full <- names(records[[which.max(lengths(records))]])
empty <- setNames(
as.list(rep(NA, length(colnames_full))),
colnames_full)
merge_lists <- function(ls_part, ls_full) {
extra <- setdiff(names(ls_full), names(ls_part))
append(ls_part, ls_full[extra])[names(ls_full)] # order as well
}
records <- lapply(records, merge_lists, empty)
records <- data.frame(
do.call(rbind, records))
head(records) # voila
|
timestamp.s position_lat.semicircles position_long.semicircles distance.m
1 833043008 629554507 -14635683 6.62
2 833043009 629554202 -14636770 13.39
3 833043010 629553899 -14637884 20.3
4 833043011 629553615 -14639020 27.25
5 833043012 629553299 -14640152 34.3
6 833043013 629552919 -14641216 41.28
accumulated_power.watts altitude.m speed.m.s power.watts heart_rate.bpm
1 267 45.2 6.511 267 114
2 467 45.2 6.754 200 115
3 692 45.2 6.83 225 116
4 931 45.2 6.902 239 116
5 1168 45.4 7.03 237 117
6 1421 45.4 6.961 253 117
cadence.rpm temperature.C left_torque_effectiveness.percent
1 69 15 91.5
2 70 15 91.5
3 70 15 78
4 72 15 78
5 72 15 81.5
6 71 15 81.5
right_torque_effectiveness.percent left_pedal_smoothness.percent
1 0 25.5
2 0 25.5
3 0 22
4 0 22
5 0 22.5
6 0 22.5
right_pedal_smoothness.percent
1 0
2 0
3 0
4 0
5 0
6 0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.