| Title: | Read FIT files using only native R code |
|---|---|
| Description: | The 'FIT' (Flexible and Interoperable Data Transfer) protocol is designed specifically for sharing data from fitness and health devices. This package allows reading 'FIT' files in pure R without any dependence on external software or SDKs. |
| Authors: | Mike Smith [aut, cre] (ORCID: <https://orcid.org/0000-0002-7800-3848>) |
| Maintainer: | Mike Smith <[email protected]> |
| License: | Artistic-2.0 |
| Version: | 0.1.11 |
| Built: | 2026-06-02 08:08:15 UTC |
| Source: | https://github.com/grimbough/FITfileR |
Methods for retrieving messages from FitFile-class objects.
listMessageTypes(fitFile) ## S4 method for signature 'FitFile' listMessageTypes(fitFile) getMessagesByType(fitFile, message_type) ## S4 method for signature 'FitFile,integer' getMessagesByType(fitFile, message_type) ## S4 method for signature 'FitFile,character' getMessagesByType(fitFile, message_type) ## S4 method for signature 'FitFile' messages(fitFile) file_id(fitFile) ## S4 method for signature 'FitFile' file_id(fitFile) records(fitFile) ## S4 method for signature 'FitFile' records(fitFile) laps(fitFile) ## S4 method for signature 'FitFile' laps(fitFile) events(fitFile) ## S4 method for signature 'FitFile' events(fitFile) hrv(fitFile) ## S4 method for signature 'FitFile' hrv(fitFile) monitoring(fitFile) ## S4 method for signature 'FitFile' monitoring(fitFile)listMessageTypes(fitFile) ## S4 method for signature 'FitFile' listMessageTypes(fitFile) getMessagesByType(fitFile, message_type) ## S4 method for signature 'FitFile,integer' getMessagesByType(fitFile, message_type) ## S4 method for signature 'FitFile,character' getMessagesByType(fitFile, message_type) ## S4 method for signature 'FitFile' messages(fitFile) file_id(fitFile) ## S4 method for signature 'FitFile' file_id(fitFile) records(fitFile) ## S4 method for signature 'FitFile' records(fitFile) laps(fitFile) ## S4 method for signature 'FitFile' laps(fitFile) events(fitFile) ## S4 method for signature 'FitFile' events(fitFile) hrv(fitFile) ## S4 method for signature 'FitFile' hrv(fitFile) monitoring(fitFile) ## S4 method for signature 'FitFile' monitoring(fitFile)
fitFile |
A |
message_type |
Either an integer or character vector (length 1), specifying either a global message number or message type respectively. |
The FIT file specification allows for a large number of message types.
FITfileR provides accessor methods for some of the most common. These
include records() and laps().
If a predefined function doesn't exist for the message type you want to
extract, any message type can be retrieved with getMessagesByType.
The second argument can take either the global message number (as specified
in the FIT File definition) of message type you want, or the message name.
A list of names for the message types held in a FitFile-class
object can be retrieved with listMessageTypes.
The return type is dependant upon whether the FitFile-class
contains multiple message definitions for the same message type. It is not
uncommon for this to occur e.g. if a new sensor is added during an activity
the records field definition will change. If there is a single definition
for the message type a tibble will be returned, otherwise a list of
tibbles is returned. The length of this list reflects the number of
unique definitions for the message type within the file. It may be
straightforward to combine these tibbles e.g. via rbind, but
this is left to the user.
Either a tibble or a list of tibble. See details for more
information.
An S4 class representing a FIT file
## S4 method for signature 'FitFile' length(x)## S4 method for signature 'FitFile' length(x)
x |
An object of class |
headerA list containing details of the file header
messagesA list of FitDataMessages
developer_msg_defsA list of lists containing the definitions for any developer messages included in the file.
Provides functionality for reading FIT (Flexible and Interoperable Data Transfer) files without any dependence on external software or SDKs.
Maintainer: Mike Smith [email protected] (ORCID)
Useful links:
FitMessageHeader class represents the single-byte header that
precedes all FIT messages. It forms a part of all
FitDefinitionMessage and FitDataMessage instances.The FitMessageHeader class represents the single-byte header that
precedes all FIT messages. It forms a part of all
FitDefinitionMessage and FitDataMessage instances.
is_defintionLogical indicating if this is a definition message.
has_developer_dataLogical defining whether the message contains developer data.
local_message_numberThe 'local' message number for this message type.
time_offsetNumeric (length 1) giving the time offset for messages with compressed time stamps.
raw_repRaw (length 1) matching the single byte that defined this message header. Used internally as a quick comparison to see if this is the same header as the previous message to speed up file reading.
S4 classes representing various aspects of FIT messages.
The FitDefinitionMessage class represents definition messages.
The FitDataMessage class holds data messages.
The FitDataMessageWithDevData class extends FitDataMessage
with additional slots to store the definitions of developer data fields that
are not defined in the standard FIT file specification.
global_message_numberA integer of length 1.
field_definitionA data.frame.
messagesA data.frame.
headerAn object of class FitMessageHeader.
definitionAn object of class FitDefinitionMessage.
fieldsA list containing the data encoded in this message.
Reads a specified FIT file and returns an object of class FitFile
readFitFile(fileName)readFitFile(fileName)
fileName |
A character specifying the FIT file to be read. |
An object of class [FitFile-class]
garmin_file <- system.file("extdata", "Activities", "garmin-edge530-ride.fit", package = "FITfileR") garmin <- readFitFile(garmin_file)garmin_file <- system.file("extdata", "Activities", "garmin-edge530-ride.fit", package = "FITfileR") garmin <- readFitFile(garmin_file)
Quickly determine what type of FIT file you have without decoding all the data. Typically types include 'activity', 'workout' and 'course'. The full range of options is defined in the FIT file specification.
readFitFileType(fileName)readFitFileType(fileName)
fileName |
A character specifying the FIT file to be read. |
As character vector of length 1. This will contain the text representation of the file type e.g. 'activity'
garmin_file <- system.file("extdata", "Activities", "garmin-edge530-ride.fit", package = "FITfileR") garmin <- readFitFileType(garmin_file)garmin_file <- system.file("extdata", "Activities", "garmin-edge530-ride.fit", package = "FITfileR") garmin <- readFitFileType(garmin_file)