Overview of the Quantified Self movement

quant_self

quant_self


A project for ANLY512: Data Visualization

The Quantified Self also known as lifelogging, is a movement to incorporate technology into data acquisition on aspects of a person’s daily life in terms of inputs (food consumed, quality of surrounding air), states (mood, arousal, blood oxygen levels), and performance, whether mental or physical. In short, quantified self is self-knowledge through self-tracking with technology.

Data collection through self-monitoring and self-sensing combines wearable sensors (e.g. EEG, ECG) and wearable computing.

Working on this project we will be looking into answering the following questions: 1. How often do I collect information related to health, steps et al using wearable technology? 2. What is my average heart rate and does it match the average heart rate for a person your age 3. How well do I sleep ? 4. What is the distance that I have covered in 2017 wearing the apple watch? 5. How many active calories have I burned in 2017.

Q1: Visualizing the hourly data and how we collected it for 2017.


We used apple watch to collect hourly data. The data collected is for 2017 and graphically shows which hours I have worn the watch.
The quantified self application was used to convert this hourly data into a csv. We then clenaed the data and added columns to create the graph.

Q2: Heart Rate analysis:


Here we see that the maximum heart rate happened when I was working out mostly on Mondays, Tuesdays and Wednesdays. The maximum heart rate also happened in the evening which clearly shows that I work out in the evenings. The heart rate is normal compared to someone my age.

Q3: Sleep cycle and proper logging of sleep data?


We see that on average I sleep around 7 to 8 hours although on some days in July the data collected was not accurate. This might be because of using the phone in the middle of night which shows that we didnt sleep well during that period.

Q4: Distance covered in 2017


We see that each month I have covered around 75 miles in distance on average. We also see taht I cover maximum distances on tuesdays and thursdays.

Q5: Steps in 2017


We see that each month the maximum amount of steps I have taken are in the 5 digits. The first graph explains how all the weekdays and months are averaged out. We also see in the second graph that I cover around 200,00 thousand steps on a monthly basis This also shows that new year resolutions work only in the January and then there is significant decline from there.

---
title: "ANLY 512 Final Project"
output: 
  flexdashboard::flex_dashboard:
    storyboard: true
    social: menu
    source: embed
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(knitr)
library(ggplot2)
library(tidyverse)
library(readxl)
library(dplyr)
library(xts)
library(zoo)
library(lubridate)
setwd("/Users/rohitmishra/Desktop/Harrisburg University/ANLY 512 Final Project/")
```
###Overview of the Quantified Self movement
![quant_self](emebrify_quantified_self_on_wrist.png)


***
A project for ANLY512: Data Visualization

The Quantified Self also known as lifelogging, is a movement to incorporate technology into data acquisition on aspects of a person's daily life in terms of inputs (food consumed, quality of surrounding air), states (mood, arousal, blood oxygen levels), and performance, whether mental or physical. In short, quantified self is self-knowledge through self-tracking with technology.

Data collection through self-monitoring and self-sensing combines wearable sensors (e.g. EEG, ECG) and wearable computing.

Working on this project we will be looking into answering the following questions:
1. How often do I collect information related to health, steps et al using wearable technology? 
2. What is my average heart rate and does it match the average heart rate for  a person your age
3. How well do I sleep ?
4. What is the distance that I have covered in 2017 wearing the apple watch? 
5. How many active calories have I burned in 2017. 


###Q1: Visualizing the hourly data and how we collected it for 2017.
```{r}
#Visualizing the hourly data and how we collected it for 2017. 
#combining the 2017 hourly data into a cleaned set
daily <- read.csv("/Users/rohitmishra/Desktop/Harrisburg University/ANLY 512 Final Project/Health Data 2_Cleaned_2017.csv")
#converting minutes asleep to hours
daily$minutes.asleep.hours <- daily$Minutes.asleep/60
daily$Weekday <- wday(parse_date_time(daily[,1], "%y/%m/%d"))
daily$Month <- month(parse_date_time(daily[,1], "%y/%m/%d"))


hourly <- read.csv("/Users/rohitmishra/Desktop/Harrisburg University/ANLY 512 Final Project/Health Data1.csv")
hourly$Day <- weekdays(strptime(hourly$Date, "%y/%m/%d"))
week <- c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
hourly$Day <- factor(hourly$Day, levels = week)
hourly$start.ct   <- as.POSIXct(paste(hourly$Date, hourly$Start, sep = " "))
hourly$finish.ct     <- as.POSIXct(paste(hourly$Date, hourly$Finish, sep = " "))
hourly$start.hour <- as.POSIXlt(hourly$start.ct)$hour + as.POSIXlt(hourly$start.ct)$min/60 + as.POSIXlt(hourly$start.ct)$sec/3600
hourly$end.hour   <- as.POSIXlt(hourly$finish.ct)$hour + as.POSIXlt(hourly$finish.ct)$min/60 + as.POSIXlt(hourly$finish.ct)$sec/3600
# offset hours if > 1 per day
hourly$ymin <- c(rep(0, nrow(hourly)))
t <- table(hourly$Day)
for(Day in rownames(t)) {
  if(t[[Day]] > 1) {
    ss <- hourly[hourly$Day == Day,]
    y  <- 0
    for(i in as.numeric(rownames(ss))) {
      hourly[i,]$ymin <- y
      y <- y + 1.2
    }
  }
}
# plot
library(ggplot2)
data_plot <- ggplot(hourly, aes(xmin = start.hour, xmax = end.hour, ymin = ymin, ymax = ymin + 1, fill = factor(Day))) + geom_rect() +
  facet_grid(Day~.) + xlim(0,23) + xlab("time of day")
data_plot

#kable(hourly[1:10,], caption="Sample hourly data")
#kable(daily[1:10,], caption="Sample Daily data")



```

***
We used apple watch to collect hourly data. The data collected is for 2017 and graphically shows which hours I have worn the watch.  
The quantified self application was used to convert this hourly data into a csv.
We then clenaed the data and added columns to create the graph. 

###Q2: Heart Rate analysis: 

```{r}


library(ggplot2)
p <- ggplot(daily, aes(daily$Weekday, daily$Heart.Rate..count.min.))
p + geom_point(aes(colour = daily$Weekday)) + scale_colour_gradient(low = "red") + labs(y= "Heart Rate per min")

hourly$Weekday <- wday(parse_date_time(hourly[,1], "%y/%m/%d"))
x <- ggplot(hourly, aes(hourly$start.hour, hourly$Heart.Rate..count.min.))
x + geom_point(aes(colour = hourly$Weekday)) + labs(y= "Heart Rate per min")

```

***
Here we see that the maximum heart rate happened when I was working out mostly on Mondays, Tuesdays and Wednesdays. 
The maximum heart rate also happened in the evening which clearly shows that I work out in the evenings. 
The heart rate is normal compared to someone my age. 

### Q3: Sleep cycle and proper logging of sleep data? 

```{r}

fill <- "maroon"
line <- "black"

Weekdayplot <- ggplot(daily, aes(x = Weekday, y=minutes.asleep.hours)) + 
  geom_boxplot(aes(group = Weekday), fill = fill, colour = line) +
  scale_x_discrete(limits=c("Sun","Mon","Tues","Wed","Thur","Fri","Sat")) +
  labs(title = "Hours asleep per week day", x = "Weekdays", y = "Hours") +
  theme_minimal()
Weekdayplot
monthlyplot <- ggplot(daily, aes(x = Month, y=minutes.asleep.hours)) + 
  geom_boxplot(aes(group = Month), fill = fill, colour = line) +
  scale_x_discrete(limits=c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")) +
  labs(title = "Hours asleep per month", x = "Months", y = "Hours") +
  theme_minimal()
monthlyplot
```

***
We see that on average I sleep around 7 to 8 hours although on some days in July the data collected was not accurate. This might be because of using the phone in the middle of night which shows that we didnt sleep well during that period. 

###Q4: Distance covered in 2017 

```{r}

library(ggplot2)
x2 <- ggplot(daily, aes(Month, Distance..mi.)) 
x2 + geom_bar(stat = "identity", fill = "purple")

library(ggplot2)
x2 <- ggplot(daily, aes(Weekday, Distance..mi.)) 
x2 + geom_bar(stat = "identity", fill = "dark green")
```

***
We see that each month I have covered around 75 miles in distance on average. 
We also see taht I cover maximum distances on tuesdays and thursdays.



###Q5: Steps in 2017

```{r}

library(ggplot2)
x3 <- ggplot(daily, aes(Month, Steps..count.))
x4 <-x3 + geom_point(aes(colour = factor(Weekday)))
x4

library(ggplot2)
daily$Steps..count. <- round(daily$Steps..count.)
x5 <- ggplot(daily, aes(Month, Steps..count./100000)) 
x5 + geom_bar(stat = "identity", fill = "dark blue") + labs(y = "Steps in hundreds of thousands")

```

***
We see that each month the maximum amount of steps I have taken are in the 5 digits. The first graph explains how all the weekdays and months are averaged out. 
We also see in the second graph that I cover around 200,00 thousand steps on a monthly basis
This also shows that new year resolutions work only in the January and then there is significant decline from there.