{"id":6643,"date":"2022-01-03T02:03:30","date_gmt":"2022-01-03T02:03:30","guid":{"rendered":"https:\/\/www.garysieling.com\/blog\/?p=6643"},"modified":"2022-01-03T02:03:30","modified_gmt":"2022-01-03T02:03:30","slug":"summarize-withings-sleep-data-from-r","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/summarize-withings-sleep-data-from-r\/","title":{"rendered":"Summarize Withings Sleep data from R"},"content":{"rendered":"\n<p>The following steps list how to export sleep data from Withings, and group\/summarize it to identify potential triggers for bad sleep.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<ol><li>install r for mac<\/li><li>install rstudio for mac<\/li><li>Export and extract withings data<\/li><li>Copy sleep.csv into a sheet named &#8216;tags&#8217;<\/li><li>Enter comments\/tags into the separate sheet<\/li><\/ol>\n\n\n\n<p>Run the following R code&#8221;<\/p>\n\n\n\n<p>install.packages(&#8220;tidyverse&#8221;)<br>library(&#8220;tidyverse&#8221;)<\/p>\n\n\n\n<p>sleep &lt;- read_csv(&#8216;\/Users\/gsieling\/Downloads\/data_abc_1234\/sleep.csv&#8217;)<br>tags &lt;- read_csv(&#8216;\/Users\/gsieling\/Downloads\/tags.csv&#8217;)<br>all &lt;- merge(sleep, tags, all.x=TRUE)<\/p>\n\n\n\n<p>names(all)[names(all) == &#8220;Average heart rate&#8221;] &lt;- &#8220;avg_heart_rate&#8221;<\/p>\n\n\n\n<p>all &lt;- all %>%<br>mutate(trigger = if_else(str_detect(Comments, &#8216;No alcohol&#8217;), &#8216;No alcohol&#8217;, &#8216;Alcohol&#8217;))<\/p>\n\n\n\n<p>all %&gt;%<br>group_by(trigger) %&gt;%<br>summarise(avg = mean(avg_heart_rate))<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/summarize-withings-sleep-data-from-r\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Summarize Withings Sleep data from R&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4,6],"tags":[628,450],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/6643"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=6643"}],"version-history":[{"count":1,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/6643\/revisions"}],"predecessor-version":[{"id":6644,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/6643\/revisions\/6644"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=6643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=6643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=6643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}