get_activity: Get Fitbit activity data in a tidy format.

Description Usage Arguments Details Value Feature description Examples

View source: R/parse_functions.R

Description

This function queries the Fitbit API and returns the activity data for different features in a tidy format.

Usage

1
2
get_activity(from_date, to_date = from_date, features = activity_features(),
  detail_level = "1min", token)

Arguments

from_date

From which date to query the data. Character scalar in the format "YYYY-MM-DD".

to_date

Up to which date to query the data. Data for that day are included in the return value. Character scalar in the format "YYYY-MM-DD".

features

A character vector listing which features should be queried and included in the final data.table. Use activity_features to see all the available features.

detail_level

A character scalar specifying how frequently should the returned data be sampled. Possible options are: '15min', '1min' and '1sec'. Use activity_features_info to get minimal sampling time for each feature.

token

Fitbit API token generated with get_fitbit_token.

Details

This is the main function of the fitbitr package. I queries the Fitbit API multiple times using the fitbit_GET function. It then parses the API outputs and combines them into a single data.table.

Value

data.table with columns corresponding to different features as described in https://dev.fitbit.com/docs/activity/ and https://dev.fitbit.com/docs/heart-rate/. Each feature also contains the daily summary denoted with a daily_ prefix.

Feature description

calories_level

Level field that reflects calculated activity level for that time period ( 0 - sedentary; 1 - lightly active; 2 - fairly active; 3 - very active.)

calories_mets

Probably the MET score https://help.fitbit.com/articles/en_US/Help_article/What-are-very-active-minutes.

calories

Calories burned in this time interval.

daily_calories

Total amount of calories burned at that day.

steps

Number of steps in this time interval.

daily_steps

Total number of steps at that day.

distance

Distance made in this time interval.

daily_distance

Total distance made at that day.

floors

Number of floors made in this time interval.

daily_floors

Number of floors made in this time interval.

elevation

Elevation units made in this time interval.

daily_elevation

Total number of elevation units made at that day.

heart

Mean heart rate in this time interval [beats per second].

daily_elevation

Daily mean heart rate [beats per second].

Currently used units are 'Metric' (described in https://dev.fitbit.com/docs/basics/#unit-systems).

Time and date are stored as character vectors.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
fitbit_token <- get_fitbit_token()
dt <- get_activity(from_date = "2015-12-15", to_date = "2015-12-18", token = fitbit_token)

## Heart rate at 1 second precision for the day 2015-12-15
dt <- get_activity(from_date = "2015-12-15", features = "heart",
                   detail_level = "1sec",
                   token = fitbit_token)

## End(Not run)

Avsecz/fitbitr documentation built on Oct. 9, 2017, 8:55 a.m.