Saturday 2 April 2016

What to do with 3.5 Million Heart Rate Monitor Readings? Part deux

In my last post I accessed 3.5 million of my Fitbit Charge HR measured heart rate data points from the Fitbit API and created this chart:



So 3.5 million data points all plotted on top of each other on a chart.  Not that instructive so time to go back to basics.

First a simple statistical summary:

> summary(FitbitHeart1)
         Date               Time           HeartRate     
 2015-10-25:  12281   06:03:30:    307   Min.   : 45.00  
 2015-05-12:  11030   04:08:20:    306   1st Qu.: 61.00  
 2015-07-18:  10716   05:54:00:    306   Median : 68.00  
 2016-02-26:  10590   03:47:10:    305   Mean   : 74.61  
 2015-09-05:  10252   05:16:40:    304   3rd Qu.: 86.00  
 2015-09-30:   9935   04:30:10:    303   Max.   :204.00  
 (Other)   :3427686   (Other) :3490659                   
 DateTimePosix                
 Min.   :2015-01-26 00:00:00  
 1st Qu.:2015-05-10 00:00:00  
 Median :2015-08-20 00:00:00  
 Mean   :2015-08-21 16:54:28  
 3rd Qu.:2015-12-07 00:00:00  
 Max.   :2016-03-16 00:00:00  

So as a simple average (mean) my heart beats 74.61 times per minute.  It went down to mumimum of 45 (presumably when sleeping) and up to a maximum of 204 (presumably during crazy exercise).

Histograms are always good fun so let's plot one with qplot.  The extra parameters set the bin width to 1 and make the  bars a more interesting colour.

>library(ggplot2)
> qplot(FitbitHeart1$HeartRate, geom="histogram", binwidth=1,main="Histogram of Heart Rate Readings",xlab="Heart Rate", ylab="Count", fill=I("blue"),col=I("red"),alpha=I(.2)) 

...which yields...

Which has an interesting profile:

  • An initial peak of lower readings, most likely during sleep / resting periods.
  • A "plateau" between 75 and 90, most likely the range for general daytime when sitting, working, moving around etc.
  • A tail off between 91 and 125, most likely more active daytime stiff, e.g. walking around.
  • A long tail from 125 to 200, most likely when exercising.

You can also do this as a density plot which gives a nice smoothed curve:

> qplot(FitbitHeart1$HeartRate, geom="density", main="Density Plot of Heart Rate Readings",xlab="Heart Rate", ylab="Density", fill=I("blue"),col=I("red"), alpha=I(.2)) 

...yielding...



From the chart I can see that the mode heart rate value is around 60 but I need to compute a table of frequencies to double check this:

> mytable <- table (FitbitHeart1$HeartRate)
> head(mytable)

  45   46   47   48   49   50 

   2   24  173  469 1383 2951 

Turn into a data frame for easier analysis:

> mydf = data.frame(mytable)
> mydf
    Var1   Freq
1     45      2
2     46     24
3     47    173
4     48    469
5     49   1383
6     50   2951
7     51   6089
8     52  12264
9     53  25178
10    54  45433
11    55  69814
12    56  94612
13    57 115236
14    58 134504
15    59 145909
16    60 152036
17    61 151795
18    62 146968
19    63 138818
20    64 127946
21    65 116876

22    66 105957

So the mode is at 60 beats per minute!

No comments:

Post a Comment