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] |
Maintainer: | Mike Smith <[email protected]> |
License: | Artistic-2.0 |
Version: | 0.1.10 |
Built: | 2024-11-04 04:34:52 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
tibble
s 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 |
header
A list containing details of the file header
messages
A list of FitDataMessages
developer_msg_defs
A 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_defintion
Logical indicating if this is a definition message.
has_developer_data
Logical defining whether the message contains developer data.
local_message_number
The 'local' message number for this message type.
time_offset
Numeric (length 1) giving the time offset for messages with compressed time stamps.
raw_rep
Raw (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_number
A integer of length 1.
field_definition
A data.frame.
messages
A data.frame.
header
An object of class FitMessageHeader
.
definition
An object of class FitDefinitionMessage
.
fields
A 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)