Package 'FITfileR'

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

Help Index


Extracting messages from FIT Files

Description

Methods for retrieving messages from FitFile-class objects.

Usage

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)

Arguments

fitFile

A FitFile-class object.

message_type

Either an integer or character vector (length 1), specifying either a global message number or message type respectively.

Details

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.

Value

Either a tibble or a list of tibble. See details for more information.


An S4 class representing a FIT file

Description

An S4 class representing a FIT file

Usage

## S4 method for signature 'FitFile'
length(x)

Arguments

x

An object of class FitFile.

Slots

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.


FITfileR: A package reading FIT files using native R code.

Description

Provides functionality for reading FIT (Flexible and Interoperable Data Transfer) files without any dependence on external software or SDKs.

Author(s)

Maintainer: Mike Smith [email protected] (ORCID)

See Also

Useful links:


The FitMessageHeader class represents the single-byte header that precedes all FIT messages. It forms a part of all FitDefinitionMessage and FitDataMessage instances.

Description

The FitMessageHeader class represents the single-byte header that precedes all FIT messages. It forms a part of all FitDefinitionMessage and FitDataMessage instances.

Slots

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.

Description

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.

Slots

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.


Read a FIT file

Description

Reads a specified FIT file and returns an object of class FitFile

Usage

readFitFile(fileName)

Arguments

fileName

A character specifying the FIT file to be read.

Value

An object of class [FitFile-class]

Examples

garmin_file <- system.file("extdata", "Activities", "garmin-edge530-ride.fit",
                           package = "FITfileR")
garmin <- readFitFile(garmin_file)