-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fitbit Intraday Data.Rmd
80 lines (62 loc) · 1.48 KB
/
Fitbit Intraday Data.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
title: "Fitbit Intraday Data"
author: "Benjamin W Nelson"
date: "1/2/2018"
output: html_document
---
##Resources:
This markdown was created by referencing these resoures.
Logon to https://dev.fitbit.com/login
https://github.com/teramonagi/fitbitr
https://dev.fitbit.com/build/reference/web-api/activity/
```{r}
# install.packages("devtools")
devtools::install_github("teramonagi/fitbitr")
```
Logon to https://dev.fitbit.com/login
Set the variables
```{r}
# As a global variable
FITBIT_KEY <- "USE YOUR FITBIT KEY"
FITBIT_SECRET <- "USE YOUR FITBIT SECRET"
FITBIT_CALLBACK <- "http://localhost:1410/"
```
Load libraries
```{r}
library(fitbitr); library(ggplot2)
```
Get Token
```{r}
token <- fitbitr::oauth_token()
```
Get Device Information
```{r}
get_devices(token)
```
Variables:
-Base date: The range start date, in the format yyyy-MM-dd or today.
-End date: The end date of the range
-Date: The end date of the period specified in the format yyyy-MM-dd or today.
-Period: The range for which data will be returned. Options are 1d, 7d, 30d, 1w, 1m, 3m, 6m, 1y
Set The Date you Want
```{r}
date <- "2018-01-01"
```
Steps
```{r}
steps <- get_activity_intraday_time_series(token, "steps", date, detail_level="15min")
steps
```
Graph Steps
```{r}
ggplot(steps, aes(x=time, y=value)) + geom_line()
```
Get Heart Rate
```{r}
hr <- get_heart_rate_intraday_time_series(token, date=date, detail_level="15min")
hr
```
Graph Heart Rate
```{r}
ggplot(hr, aes(x=time, y=value)) + geom_line()
```