Heart Rate

When the new Charge 2 was released I upgraded and started using that exclusively to track my activity and 24/7 heart rate. Fitabase offers the capability to access the highest resolution heart rate data available through the Fitbit API. Typically that means a heart rate recording every 5-10 seconds or so. That’s a lot of data! Probably too much for this exploration, so I exported my per minute average heart rate from Fitabase and plotted that.

# read in the data
minuteheart <- read.csv("~/Downloads/ID 1003_heartrate_1min_20160701_20170117.csv")

# have to reformat the datetime variable
library(lubridate)
minuteheart$Time <- mdy_hms(as.character(minuteheart$Time))

# create an xts time series object for use with dygraph package
library(xts)
minuteheartxts <- xts(minuteheart$Value, minuteheart$Time)


Heart Rate Plot

Sweet! Let’s get those 8,587,723 heartbeats plotted!

library(dygraphs)
dygraph(minuteheartxts , main = "My 8.6 Million Heartbeats", ylab="Heart Rate (minute avg)") %>%
  dySeries("V1", label = "Heart Rate", color ="#EF426F") %>% 
  dyLegend(show = "always", hideOnMouseOut = FALSE, width = 400) %>%
  dyOptions(useDataTimezone = TRUE) %>%
 
  dyRangeSelector() 



How about we add some more detail to the heart rate plot? Fitbit does some automatic hear rate zone classification based on estimated maximal heart rate.

dygraph(minuteheartxts , main = "My 8.6 Million Heartbeats", ylab="Heart Rate (minute avg)") %>%
  dySeries("V1", label = "Heart Rate", color ="black") %>% 
  dyLegend(show = "always", hideOnMouseOut = FALSE, width = 400) %>%
  dyOptions(useDataTimezone = TRUE) %>%
  dyRangeSelector() %>%
  dyShading(from = 0, to = 92, axis = "y", color="grey") %>%
  dyShading(from = 92, to = 128, axis = "y", color="yellow") %>%
  dyShading(from = 128, to = 156, axis = "y", color="orange") %>%
  dyShading(from = 156, to = 184, axis = "y", color="red")