The following steps list how to export sleep data from Withings, and group/summarize it to identify potential triggers for bad sleep.
The comments in the app are not exportable, but one could use the app to track comma separated tags, re-record later, and run this process.
- install r for mac
- install rstudio for mac
- Export and extract withings data
- Copy sleep.csv into a sheet named ‘tags’
- Enter comments/tags into the separate sheet
Run the following R code”
install.packages(“tidyverse”)
library(“tidyverse”)
sleep <- read_csv(‘/Users/gsieling/Downloads/data_abc_1234/sleep.csv’)
tags <- read_csv(‘/Users/gsieling/Downloads/tags.csv’)
all <- merge(sleep, tags, all.x=TRUE)
names(all)[names(all) == “Average heart rate”] <- “avg_heart_rate”
all <- all %>%
mutate(trigger = if_else(str_detect(Comments, ‘No alcohol’), ‘No alcohol’, ‘Alcohol’))
all %>%
group_by(trigger) %>%
summarise(avg = mean(avg_heart_rate))