RConf 2022

Introduction to the Apple Health Export

John Goldin

Curious about all that health and fitness data on your iPhone? R can help.

  • There may be millions of rows of data about you on your phone

  • Whether that data is actually useful is an open question – help answer it

A personal story…

…me and my Apple watch.

An Introduction to the
Apple Health Export

John Goldin
July 28, 2022

Heart Rate on y-axis rising to 150 at 5:30 AM

Another view of heart rate with arrow pointing to pulse of 150

Arrow pointing to earlier somewhat elevated pulse at 1:30 AM

Arrow highlighting incraese in heart rate during night

Another view of heart rate with arrow pointing to pulse of 150

There’s a Ton of MY Data

3.9 million rows total

1.2 million rows from the last year

BUT…mostly heart rate and low level movement

AND…69% of non-workout rows are from only top four types

  • Heart Rate
  • Active Energy (calories)
  • Basal Energy (calories)
  • Distance (walk or run)

Categories in the
Health App
health categories available in Apple Health app

Categories in the
Health App
health categories available in Apple Health app

A Smorgasbord of Measures

Active Energy Burned , Basal Energy Burned , Distance Walking Running , Step Count , Apple Exercise Time , Apple Stand Time , Flights Climbed , Apple Stand Hour , Distance Cycling , Body Mass , Height , Environmental Audio Exposure , Headphone Audio Exposure , Audio Exposure Event , Heart Rate , Blood Pressure Diastolic , Blood Pressure Systolic , Heart Rate Variability S D N N , Resting Heart Rate , Walking Heart Rate Average , VO2 Max , E C G Other Symptom , Mindful Session , Walking Step Length , Walking Speed , Walking Double Support Percentage , Stair Ascent Speed , Stair Descent Speed , Walking Asymmetry Percentage , Apple Walking Steadiness , Six Minute Walk Test Distance , Dietary Fat Total , Dietary Energy Consumed , Dietary Protein , Dietary Fiber , Dietary Fat Saturated , Dietary Sodium , Dietary Sugar , Dietary Cholesterol , Dietary Caffeine , Dietary Carbohydrates , Respiratory Rate , Oxygen Saturation , Sleep Analysis , Low Heart Rate Event , Rapid Pounding or Fluttering Heartbeat , Dizziness , Low Heart Rate Event , Number of Times Fallen , oal

What is the Apple Health Export?

data going from devices into Apple Health Kit and then to Health Export

Most data ends up in one large tidy table (health_xml)

  • start time stamp
  • end time stamp
  • type (what is being measured)
  • value
  • source
  • version

You will focus on type and value

but pay attention to source and version


For example, Watch and iPhone may report steps for the same time period.

Resting Heart Rate

Daily resting heart rate from 2018 to present with smoothed trend line

Resting Heart Rate (with version)

Daily resting heart rate from 2018 to present with smoothed trend line

VO2max
(a measure of aerobic fitness)

Estimated VO2max from 2018 to present

VO2max – with version
(a measure of aerobic fitness)

Same plot of VO2max, but this version includes version number of watch

Atrial Fibrillation

using apple watch to create ECG

Another Visit to the ER

Pulse on x-axis during showing elevated heart rate during period of atrial fibrillation and marking when Watch electrocardiogram taken

For more information…

A series of blog posts on the Apple Health Export at
https://www.johngoldin.com/blog/apple-health-export/


Some examples of what people have done with their personal data:
https://quantifiedself.com/show-and-tell/


Want to try your dplyr skills but tired of Diamonds or Palmer Penguins? Export your health and fitness data and go to work.