This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| install.packages("lubridate") | |
| library(lubridate) | |
| #make endDate in a date-time variable POSIXct using lubridate with Indian time zone | |
| df$endDate <-ymd_hms(df$endDate,tz="UTC") | |
| #new features | |
| df$month<-format(df$endDate,"%m") | |
| df$year<-format(df$endDate,"%Y") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| install.packages("XML") | |
| library(XML) | |
| xml <- xmlParse("export.xml") | |
| summary(xml) | |
| #convert the XML object to data frame | |
| df <- XML:::xmlAttrsToDataFrame(xml["//Record"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| heart_rate <- df %>% | |
| filter(type == 'HKQuantityTypeIdentifierHeartRate') %>% | |
| group_by(date,year,month) %>% | |
| summarize(heart_rate=mean(value)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| p1 <- ggplot(heart_rate,aes(x=date, y=heart_rate, group=year)) + | |
| geom_line(aes(colour=year))+ | |
| ggtitle("Mean heartrate over the months") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| heart_rate <- df %>% | |
| filter(type == 'HKQuantityTypeIdentifierHeartRate') %>% | |
| group_by(date,year,month) %>% | |
| summarize(heart_rate=median(value))+ | |
| xlab("Month/Year") | |
| heart_rate$date <- as.Date(heart_rate$date,"%Y-%m-%d") | |
| plot <- ggplot(heart_rate,aes(x=date, y=heart_rate, group=year)) + | |
| geom_line(aes(colour=year))+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| steps <- df %>% | |
| filter(type == 'HKQuantityTypeIdentifierStepCount') %>% | |
| group_by(date,year,month) %>% | |
| summarize(steps=sum(value)) | |
| steps$date <- as.Date(steps$date,"%Y-%m-%d") | |
| plot2 <- ggplot(steps,aes(x=date, y=steps, group=year)) + | |
| geom_line(aes(colour=year))+ | |
| geom_snooth(se=F)+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| step_count <- df %>% | |
| filter(type == 'HKQuantityTypeIdentifierStepCount') %>% | |
| filter(year==2019) %>% | |
| group_by(dayofweek,year,month) %>% | |
| summarize(step_count=median(value)) | |
| plot <- ggplot(step_count,aes(x=month, y=step_count, group=dayofweek)) + | |
| geom_line(aes(colour=dayofweek),size=1.5)+ | |
| theme_minimal()+ | |
| ggtitle("Weekly median stepcount") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| str(df) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| table(df$type) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| install.packages("tidyverse") | |
| install.packages("ggplot2") | |
| library(tidyverse) | |
| library(ggplot2) |
OlderNewer