Learn R Programming

fitcoach (version 1.0)

DataLoader: R6 class for Loading Fitbit data

Description

DataLoader is an R6 Class that connects to the Fitbit API with the credentials, requests the data, and writes the response to JSON files,

Usage

DataLoader

Arguments

Format

A R6Class generator object

Methods

connect(appname, key, secret, cache.file)
This method connects to the Fitbit API and to your application. appname: Name of the Fitbit App key: Fitbit API Client key secret: Fibit API Client secret cache.file: Path to a cached token file, instead of providing credentials in the function call
request(type = "day", activities = "", start.date = Sys.Date(), end.date = "", path = "./json/"))
This method builds the request URLs, sends the requests and writes response to JSON files, in the specified folder. type: Type of time series. Must be 'day' or 'intraday'. activities: A list of the Fitibit activities to be retrieved. start.date: Start date in format YYYY-mm-dd. end.date: End date in format YYYY-mm-dd. path: Folder where the JSON files will be written.

Examples

Run this code
## Not run: 
# testObject <- DataLoader$new()
# 
# testObject$connect(appname = "abcd",
#                    key = "123ABC",
#                    secret = "3089e3h1ac9dde0aa67b54ajc8691j44")
# 
# testObject$request(
#     type = 'day', 
#     activities = list("calories", "steps", "distance", "minutesVeryActive"), 
#     start.date = "2016-01-01", 
#     end.date = "2016-02-01", 
#     path = "~/fitbit-daily/")
# ## End(Not run)

Run the code above in your browser using DataLab