Parses an Apple Health export.xml into a tidy set of records and workout
summaries. Every sample Apple stores as a <Record> – heart rate, heart-rate
variability (HeartRateVariabilitySDNN), blood oxygen (OxygenSaturation),
respiratory rate, step count, active/basal energy, resting and walking heart
rate, VO2 max, and SleepAnalysis sleep stages – becomes one row; <Workout>
elements become the workouts table. The reader streams the file, so multi-
hundred-MB exports are handled without loading the whole document into memory.
Value
An apple_health object: a list with records (a data frame with
type, source, unit, start, end, value, value_num), workouts
(or NULL), path and tz.
Details
The Apple type prefix (HKQuantityTypeIdentifier / HKCategoryTypeIdentifier)
is stripped, so type reads e.g. "HeartRate", "OxygenSaturation",
"SleepAnalysis". Numeric samples are parsed into value_num; category
samples (sleep stages) keep their (prefix-stripped) label in value.
Examples
if (FALSE) { # \dontrun{
ah <- readAppleHealth("apple_health_export/export.xml", tz = "Asia/Tokyo")
appleHealthTypes(ah)
hr <- appleHealthSeries(ah, "HeartRate")
} # }