The Quantified Self assignment overview


A project for ANLY512: Data Visualization

The Quantified Self movement grew from the popularity and growth of the internet of things, the mass collection of personal information, and mobile technologies (primarily wearable computing). This final class project uses a collection of seven months of data on sleep habits and physical activity captured by an activity tracker. In particular, I used a Fitbit Charge 2 which tracks a wide variety of data points related to body, food intake, physical activity, and sleep.

The goal of the project is to collect, analyze and visualize the data using the tools and methods covered in class. Additionally, using the data-driven approach, I will create a summary which answers the following questions 1) how much sleep am I getting 2) how does an abundance or lack of sleep affect my activity level 3) when am I the most active 4) how do ‘Number of Awakenings’ effect my sleep 5) how accurate is the Charge 2.

Preparing raw data for analysis

First 13 data records
Date Calories.Burned Steps Distance Floors Minutes.Sedentary Minutes.Lightly.Active Minutes.Fairly.Active Minutes.Very.Active Activity.Calories Minutes.Asleep Minutes.Awake Number.of.Awakenings Time.in.Bed
1/1/17 3,429 12,219 5.36 16 527 350 48 27 2,104 6.8 30 2 438
1/2/17 2,237 4,407 1.93 10 697 138 7 4 625 9.2 31 4 592
1/3/17 2,256 5,434 2.38 13 864 174 0 0 706 7.1 20 1 448
1/4/17 2,707 8,908 3.91 13 764 248 14 9 1,192 6.3 31 2 411
1/5/17 2,314 5,259 2.31 18 860 194 0 0 792 6.2 16 1 386
1/6/17 2,799 10,043 4.41 11 715 288 12 22 1,415 6.5 9 2 403
1/7/17 2,663 10,315 4.53 6 640 312 6 1 1,294 7.3 42 3 481
1/8/17 2,500 8,404 3.69 11 725 231 6 2 1,002 7.6 20 0 476
1/9/17 2,863 9,626 4.22 17 731 275 16 23 1,371 6.1 31 3 395
1/10/17 2,654 8,454 3.71 17 756 292 0 0 1,230 6.1 26 2 392
1/11/17 2,484 7,575 3.32 7 700 279 0 0 1,072 7.4 15 1 461
1/12/17 2,449 6,531 2.87 14 868 220 4 4 895 5.4 20 2 344
1/13/17 2,489 8,251 3.62 11 771 241 0 0 1,006 6.7 25 1 424
      Date     Calories.Burned     Steps        Distance    
 1/1/17 :  1   2,462  :  3     7,212  :  2   Min.   :0.010  
 1/10/17:  1   2,473  :  3     8,251  :  2   1st Qu.:1.990  
 1/11/17:  1   2,484  :  3     8,454  :  2   Median :2.850  
 1/12/17:  1   2,051  :  2     1,163  :  1   Mean   :2.858  
 1/13/17:  1   2,075  :  2     1,344  :  1   3rd Qu.:3.562  
 1/14/17:  1   2,246  :  2     1,459  :  1   Max.   :7.730  
 (Other):192   (Other):183     (Other):189                  
     Floors      Minutes.Sedentary Minutes.Lightly.Active
 Min.   : 0.00   800    :  4       Min.   :  3.0         
 1st Qu.: 7.00   840    :  4       1st Qu.:150.0         
 Median :10.00   648    :  3       Median :204.0         
 Mean   :11.09   749    :  3       Mean   :205.2         
 3rd Qu.:14.75   792    :  3       3rd Qu.:257.0         
 Max.   :28.00   794    :  3       Max.   :353.0         
                 (Other):178                             
 Minutes.Fairly.Active Minutes.Very.Active Activity.Calories
 Min.   : 0.000        Min.   : 0.000      706    :  3      
 1st Qu.: 0.000        1st Qu.: 0.000      1,002  :  2      
 Median : 0.000        Median : 0.000      1,031  :  2      
 Mean   : 6.333        Mean   : 9.742      1,071  :  2      
 3rd Qu.: 8.000        3rd Qu.: 9.000      1,104  :  2      
 Max.   :58.000        Max.   :73.000      1,294  :  2      
                                           (Other):185      
 Minutes.Asleep   Minutes.Awake Number.of.Awakenings  Time.in.Bed   
 Min.   : 2.100   Min.   : 1    Min.   :0.000        Min.   :134.0  
 1st Qu.: 6.000   1st Qu.:17    1st Qu.:1.000        1st Qu.:375.2  
 Median : 6.800   Median :25    Median :1.000        Median :430.5  
 Mean   : 6.715   Mean   :26    Mean   :1.722        Mean   :429.9  
 3rd Qu.: 7.575   3rd Qu.:31    3rd Qu.:2.000        3rd Qu.:486.0  
 Max.   :10.100   Max.   :72    Max.   :9.000        Max.   :652.0  
                                                                    
 Total.Activity   Weekday       Month   
 Min.   :0.000   Sun  :28   Jan    :31  
 1st Qu.:2.800   Mon  :31   Apr    :30  
 Median :3.600   Tues :30   Mar    :29  
 Mean   :3.687   Wed  :26   May    :28  
 3rd Qu.:4.575   Thurs:27   Jun    :27  
 Max.   :7.100   Fri  :28   Jul    :27  
                 Sat  :28   (Other):26  

Preparing the data for analysis

When worn, the tracking device displays the number of flights climbed, steps taken, heartrate, and calories burned but only for the current day. But the fitbit website provides tools for exporting tubular data groupd by categories, but only in 31 day increments.

So to begin the data preparation process, I exported the body and sleep documents in comman seperated value (csv) format for each month and combined the files into one spreadsheet in Excel. During this process I also identified which factors were missing but would be needed for analysis. These were 1) converting minute values to hours, 2) summing the activity values into a total column, and 3) extracting month and day of week from “mdy”" date values. All of whichwould be done once the data was imported into R Studio.

The first table presented here provides a glimpse at the observations collected by the Charge 2. Once all values were validated for data types and missing or NA records were removed, the content was imported using the read.csv command.

The second table is the summary document created within R Studio. This table was presented to identify statistical information about the dataset.

Question 1:
Am I getting enough sleep and exercise?


To answer this question I located the following two facts.

  1. According to a February 2016 report on Morbidity and Mortality, Centers for Disease Control and Prevention’s (CDC) announced that “More than a third of American adults are not getting enough sleep on a regular basis”. The report recommends that adults 18-60 years old should get at least 7 hours of sleep. https://www.cdc.gov/media/releases/2016/p0215-enough-sleep.html

  2. Both the American College of Sports Medicine and the American Heart Association recommend two and half hours a week of moderate intensity exercise. http://www.cnn.com/2017/03/29/health/how-much-exercise-metzl/index.html

Using these facts as guidelines I creates a series of plots of the amount of sleep (1.1) and the amount of moderate exercise (1.2) for each day of the observed range. And the results are pretty obvious. (1.3) and (1.4) are histograms which illustrate similar information, but in this case the comparison includes ‘Day of the Week’. The plots show the frequency at which I got more that 7 hours of sleep and more than .35 hrs (21 minutes) of moderate exercise.

Question 2:
What are my weekly and monthly sleep habits?


The current dashboard available at FitBit.com provides a look at weekly sleep and activity data, but it does not provide a broader view of the information over time. They focus on a view of your current information, displaying daily summaries for the current week. In contrast, 2.1 and 2.2 are boxplots which show the over all quality of my sleep patterns over broader time periods. Something not possible from the current website.

2.1 clearly shows that I tend to get less sleep on Thursdays, while 2.2 indicates that the mean value of the hours of sleep I get per night for each month is between 6.5 and 6.9, just below the recommended levels.

A view of the existing dashboard is available here - http://fitbit.link/2x9B2U1.

Question 3:
When am I the most active?


This 3.1 Moderate activity heatmap illustrates the sum of the ‘Moderately Activity’ and ‘Very Active’ recorded by the device each day. The brighter the rectangle the greater the amount of active time for that date. Additionally, the horizontal rows disect the information into weeks.

From the plot we can see that I have not been active enough as suggested by the American College of Sports Medicine and the American Heart Association.

Anecdotally, it’s interesting to note that 9th week shows a high level of activity. Going back to my calendar I saw that this was the week of a conference I presented at. With my hotel being almost a mile from the convention center and the size of the event, I did a lot of walking.

Plot 3.2 compares the mean values of each day from the heatmap. Although the heatmap creates a great visual, this chart quantifies the data and shows that I get the most activity on Mondays.

Question 4:
Compare daily activity to daily sleep?


This simple chart is a quick comparison of the daily sleep and exercise amounts. Roll over any point to see the point values. Color (purple to pink) shows increased sleep and size aligns to exercise amounts.

Question 5:
Is there a relatinoship between the number of awakenings and quality of sleep?


I was pretty sure that awakening multiple times in the night disrupted my sleep, but I had no way of knwing how the awakenings effect the amount of time asleep. But the results show something different. In total, I received the most sleep with there were 1 or 5 awakenings. The dot indicate the number of hours of activity on each day when plotted against awakenings. Although there isn’t a strong coorelation, there were more observations of activity on days with fewer awakenings.

Additional observations:


This is a collection of addtional charts created during the process.

6.1 A look at hours asleep per month. Although we tend to stay away from pie charts, here it is acceptable because instead of using the chart to illustrate the differences between each month, I am using the wedges to show how similar the values are.

6.2 uses geom_hex() to compare hours of sleep to awakenings.

6.3 & 6.4 provide a look at the hours of sleep by day of week and month of activity.

Summary


The next step is to test this dashboard by loadling datasets from other users. Althought I chose to use the storyboard version of Flex Dashboard, I believe using Shiny widgets would create a more interactive solution, providing the option for users to select the metrics for comparison.

For me, the overall success of this project came from being able to create data visualizations which promote the Quantified Self movement. I learned a tremendous amount about presenting information using ggplot, skills which will help me moving forward as a student, educator, and future data scientist.

---
title: "Fitbit Dashboard"
output: 
  flexdashboard::flex_dashboard:
    storyboard: true
    social: menu
    source: embed

---
                    

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(flexdashboard)
library(knitr)
library(kableExtra)
library(ggplot2)
library(tidyverse)
library(readxl)
library(dplyr)
library(xts)
library(zoo)
library(lubridate) 
library(cowplot)

fit <- read.csv("~/Documents/CourseWork/Grad Program/Summer 2017/Final Assignment/fitbit_dataset.csv")
fit_rev <- subset(fit, fit$Time.in.Bed > 0)

## combine activity values into a summary column
fit_rev$Total.Activity <- round((fit_rev[,7]+fit_rev[,8]+fit_rev[,9])/60, digits=1)

## convert minutes to hours
fit_rev$Minutes.Asleep <- round(fit_rev[,11]/60, digits=1)


month_levels <- c(
  "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
)

weekday_levels <- c(
  "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
)

## create day of week day column
fit_rev$Weekday <- wday(parse_date_time(fit_rev[,1], 'mdy'), label=TRUE)

## create day of week day column
fit_rev$Month <- month(parse_date_time(fit_rev[,1], 'mdy'), label=TRUE)

options(knitr.table.format = "html") 

```

### The Quantified Self assignment overview

```{r Opening plot}
ggplot(fit_rev, aes(Date, Minutes.Asleep, colour=factor(Weekday))) + 
  geom_point(alpha=.3, size = fit_rev$Distance*3) +
  labs(x = "Jan 1 - Jul 31", y = "Hours", 
       title = "7 months of sleep data") +
  theme(legend.position="none", 
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank(), 
        panel.grid.major = element_blank())
```

***
A project for ANLY512: Data Visualization

The Quantified Self movement grew from the popularity and growth of the internet of things, the mass collection of personal information, and mobile technologies (primarily wearable computing). This final class project uses a collection of seven months of data on sleep habits and physical activity captured by an activity tracker. In particular, I used a Fitbit Charge 2 which tracks a wide variety of data points related to body, food intake, physical activity, and sleep. 

The goal of the project is to collect, analyze and visualize the data using the tools and methods covered in class. Additionally, using the data-driven approach, I will create a summary which answers the following questions 1) how much sleep am I getting 2) how does an abundance or lack of sleep affect my activity level 3) when am I the most active 4) how do 'Number of Awakenings' effect my sleep 5) how accurate is the Charge 2.


### Preparing raw data for analysis

```{r}
kable(fit_rev[1:13,1:14], caption="First 13 data records") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))

summary(fit_rev)
```

***

Preparing the data for analysis

When worn, the tracking device displays the number of flights climbed, steps taken, heartrate, and calories burned but only for the current day. But the fitbit website provides tools for exporting tubular data groupd by categories, but only in 31 day increments.

So to begin the data preparation process, I exported the body and sleep documents in comman seperated value (csv) format for each month and combined the files into one spreadsheet in Excel. During this process I also identified which factors were missing but would be needed for analysis. These were 1) converting minute values to hours, 2) summing the activity values into a total column, and 3) extracting month and day of week from "mdy"" date values. All of whichwould be done once the data was imported into R Studio.

The first table presented here provides a glimpse at the observations collected by the Charge 2. Once all values were validated for data types and missing or NA records were removed, the content was imported using the read.csv command. 

The second table is the summary document created within R Studio. This table was presented to identify statistical information about the dataset.


### Question 1:
Am I getting enough sleep and exercise? ```{r} fit20Dn <- fit20Up <- fit7Dn <- fit7Up <- fit_rev[c(1,11,16)] fit7Up <- subset(fit7Up, fit_rev$Minutes.Asleep >= 7) fit7Dn <- subset(fit7Dn, fit_rev$Minutes.Asleep < 7 & fit_rev$Minutes.Asleep > 3) fit20Dn$Activity <- (fit_rev$Minutes.Fairly.Active + fit_rev$Minutes.Very.Active)/60 fit20Up$Activity <- (fit_rev$Minutes.Fairly.Active + fit_rev$Minutes.Very.Active)/60 fit20Up <- subset(fit20Up, fit20Up$Activity >= .35) fit20Dn <- subset(fit20Dn, fit20Dn$Activity < .35) p1 <- ggplot(fit7Up, aes(x=Date, y=Minutes.Asleep)) + geom_point(colour = "green", alpha=.5, size=(max(fit7Up$Minutes.Asleep)+1-fit7Up$Minutes.Asleep)) + geom_point(data=fit7Dn, colour="red", alpha=.5, size=(fit7Dn$Minutes.Asleep/max(fit7Dn$Minutes.Asleep)*3)) + annotate("rect", xmin = 150, xmax = 195, ymin = 8.5, ymax = 9, alpha = .4) + annotate("rect", xmin = 150, xmax = 195, ymin = 4.5, ymax = 5, alpha = .4) + annotate("text", x = 175, y = 8.75, label = "38.9% (7+ Hours)", size = 3, colour = "black") + annotate("text", x = 175, y = 4.75, label = "61.1% (< 7 Hours)", size = 3, colour = "black") + annotate("segment", x = 2.5, xend = 200, y = 7, yend = 7, colour = "black") + scale_x_discrete(expand = c(0, 0)) + scale_y_discrete(expand = c(0, 0)) + labs(x = "Jan 1 - Jul 31", y = "Hours asleep", title = "1.1 Recommended sleeping time") + theme(legend.position="none", axis.text.x=element_blank(), axis.ticks.x=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank(), panel.grid.major = element_blank()) p2 <- ggplot(fit20Up, aes(x=Date, y=Activity)) + geom_point(colour = "green", alpha=.5, size=2) + geom_point(data=fit20Dn, colour="red", alpha=.5, size=2) + annotate("rect", xmin = 150, xmax = 195, ymin = .35, ymax = .55, alpha = .4) + annotate("rect", xmin = 150, xmax = 195, ymin = .15, ymax = .35, alpha = .4) + annotate("text", x = 175, y = .45, label = "24.75% (21+ minutes)", size = 3, colour = "black") + annotate("text", x = 175, y = .25, label = "75.25% (< 21 minutes)", size = 3, colour = "black") + annotate("segment", x = 2.5, xend = 200, y = .35, yend = .35, colour = "black") + scale_x_discrete(expand = c(0, 0)) + scale_y_discrete(expand = c(0, 0)) + labs(x = "Jan 1 - Jul 31", y = "Activity time (minutes)", title = "1.2 Recommended exercise time") + theme(legend.position="none", axis.text.x=element_blank(), axis.ticks.x=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank(), panel.grid.major = element_blank()) p3 <- ggplot(fit7Up, aes(x=Minutes.Asleep, fill=Weekday)) + geom_histogram(colour="black", binwidth=.3) + labs(x = "Hours of Sleep", y="") + facet_wrap(~Weekday) + guides(fill=FALSE) + theme_bw() + labs(x = "7+ Hours of sleep", y = "Count", title = "1.3 Frequency of recommended sleep times") p4 <- ggplot(fit20Up, aes(x=Activity, fill=Weekday)) + geom_histogram(colour="black", binwidth=.3) + labs(x = "Hours of Sleep", y="") + facet_wrap(~Weekday) + guides(fill=FALSE) + theme_bw() + labs(x = "7+ Hours of sleep", y = "Count", title = "1.4 Frequency of daily activity times") p1 p2 p3 p4 ``` *** To answer this question I located the following two facts. 1) According to a February 2016 report on Morbidity and Mortality, Centers for Disease Control and Prevention's (CDC) announced that "More than a third of American adults are not getting enough sleep on a regular basis". The report recommends that adults 18-60 years old should get at least 7 hours of sleep. https://www.cdc.gov/media/releases/2016/p0215-enough-sleep.html 2) Both the American College of Sports Medicine and the American Heart Association recommend two and half hours a week of moderate intensity exercise. http://www.cnn.com/2017/03/29/health/how-much-exercise-metzl/index.html Using these facts as guidelines I creates a series of plots of the amount of sleep (1.1) and the amount of moderate exercise (1.2) for each day of the observed range. And the results are pretty obvious. (1.3) and (1.4) are histograms which illustrate similar information, but in this case the comparison includes 'Day of the Week'. The plots show the frequency at which I got more that 7 hours of sleep and more than .35 hrs (21 minutes) of moderate exercise. ### Question 2:
What are my weekly and monthly sleep habits? ```{r} fill <- "gold1" line <- "goldenrod2" #fit_rev$Weekday <- factor(fit_rev$Weekday, levels=c("Sunday", "Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")) ggplot(fit_rev, aes(x = Weekday, y=Minutes.Asleep)) + geom_boxplot(aes(group = Weekday), fill = fill, colour = line) + scale_x_discrete(limits=c("Sun","Mon","Tues","Wed","Thurs","Fri","Sat")) + labs(title = "2.1 Hours asleep per week day", x = "Weekdays", y = "Hours") + theme_minimal() ggplot(fit_rev, aes(x = Month, y=Minutes.Asleep)) + geom_boxplot(aes(group = Month), fill = fill, colour = line) + scale_x_discrete(limits=c("Jan","Feb","Mar","Apr","May","Jun","Jul")) + labs(title = "2.2 Hours asleep per month", x = "Months", y = "Hours") + theme_minimal() ``` *** The current dashboard available at FitBit.com provides a look at weekly sleep and activity data, but it does not provide a broader view of the information over time. They focus on a view of your current information, displaying daily summaries for the current week. In contrast, 2.1 and 2.2 are boxplots which show the over all quality of my sleep patterns over broader time periods. Something not possible from the current website. 2.1 clearly shows that I tend to get less sleep on Thursdays, while 2.2 indicates that the mean value of the hours of sleep I get per night for each month is between 6.5 and 6.9, just below the recommended levels. A view of the existing dashboard is available here - http://fitbit.link/2x9B2U1. ### Question 3:
When am I the most active? ```{r} #library(metricsgraphics) #mjs_plot(mtcars, x=wt, y=mpg) %>% # mjs_point(color_accessor=carb, size_accessor=carb) %>% # mjs_labs(x="Weight of Car", y="Miles per Gallon") fit3 <- read.csv("~/Documents/CourseWork/Grad Program/Summer 2017/Final Assignment/fitbit_dataset.csv") fit3 <- fit3[c(1,7:9,11)] #fit3$Minutes.Asleep <- round(fit3$Minutes.Asleep/60,1) fit3$Total.Activity <- round((fit3[,2]+fit3[,3]+fit3[,4]), digits=1) fit3$Weekday <- wday(parse_date_time(fit3[,1], 'mdy'), label=TRUE) fit3$Month <- month(parse_date_time(fit3[,1], 'mdy'), label=TRUE) fit3$Levels <- factor(fit3$Minutes.Very.Active) N <- nlevels(fit3$Levels) colors <- colorRampPalette(c("#336611", "#99FF33"))(length(unique(fit3$Levels))) ggplot(fit3) + geom_tile(aes(x=Weekday, y=week(parse_date_time(fit3[,1],'mdy')), fill=Levels)) + scale_fill_manual(values=colors, breaks=levels(fit3$Levels)[seq(1, N, by=5)]) + labs(title = "3.1 Moderate activity", x = "Weekdays", y = "31 Weeks", show.legend = FALSE) + scale_x_discrete(expand = c(0, 0)) + scale_y_discrete(expand = c(0, 0)) actAGG <- aggregate(fit3$Total.Activity ~ fit3$Weekday , data=fit3, mean) colnames(actAGG)[1] <- "Weekday" colnames(actAGG)[2] <- "Activity" #kable(actAGG, caption="Mean value of activity data") %>% # kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive")) ggplot(actAGG, aes(x=Weekday)) + geom_bar(aes(weight = Activity, fill=Weekday)) + labs(title = "3.2 Activity summary", x = "Weekdays", y = "Activity Mean", show.legend = FALSE) + theme(legend.position="none", axis.ticks.x=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank(), panel.grid.major = element_blank()) ``` *** This 3.1 Moderate activity heatmap illustrates the sum of the 'Moderately Activity' and 'Very Active' recorded by the device each day. The brighter the rectangle the greater the amount of active time for that date. Additionally, the horizontal rows disect the information into weeks. From the plot we can see that I have not been active enough as suggested by the American College of Sports Medicine and the American Heart Association. Anecdotally, it's interesting to note that 9th week shows a high level of activity. Going back to my calendar I saw that this was the week of a conference I presented at. With my hotel being almost a mile from the convention center and the size of the event, I did a lot of walking. Plot 3.2 compares the mean values of each day from the heatmap. Although the heatmap creates a great visual, this chart quantifies the data and shows that I get the most activity on Mondays. ### Question 4:
Compare daily activity to daily sleep? ```{r} library(metricsgraphics) mjs_plot(fit_rev, x=Minutes.Asleep, y=Total.Activity) %>% mjs_point(color_accessor=Minutes.Asleep, size_accessor=Total.Activity) %>% mjs_labs(x="Sleep", y="Activity") ``` *** This simple chart is a quick comparison of the daily sleep and exercise amounts. Roll over any point to see the point values. Color (purple to pink) shows increased sleep and size aligns to exercise amounts. ### Question 5:
Is there a relatinoship between the number of awakenings and quality of sleep? ```{r} q5 <- fit_rev[c(11,13,15)] q5 <- subset(q5, Number.of.Awakenings < 6) #plot(q5[,2:3]) ggplot(q5, aes(Number.of.Awakenings, Minutes.Asleep, fill=Minutes.Asleep)) + geom_col(position="dodge") + geom_point(data=q5$Activity.Calories) + labs(title = "5.1 Awakenings", x = "Awakenings per night", y = "Hours asleep (stacked)", show.legend = FALSE) ``` *** I was pretty sure that awakening multiple times in the night disrupted my sleep, but I had no way of knwing how the awakenings effect the amount of time asleep. But the results show something different. In total, I received the most sleep with there were 1 or 5 awakenings. The dot indicate the number of hours of activity on each day when plotted against awakenings. Although there isn't a strong coorelation, there were more observations of activity on days with fewer awakenings. ### Additional observations: ```{r} fit_bg <- fit_rev[,-17] ggplot(fit_rev, aes(x=factor(1), y=Minutes.Asleep, fill=Month)) + geom_bar(aes(group = Month), width = 1, stat = "identity") + coord_polar("y", start=0) + labs(title = "6.1 Sleep per month", y = "Hours of Sleep", x="") + theme_minimal() ggplot(fit_rev, aes(Number.of.Awakenings, Activity.Calories, colour=Number.of.Awakenings))+ geom_hex() + labs(title = "6.2 Sleep per month", y = "Hours of Sleep", x="") + theme(axis.ticks.x=element_blank(), axis.text.y=element_blank(), panel.grid.major = element_blank()) ggplot(fit_rev, aes(x=Minutes.Asleep, fill=Weekday)) + #geom_histogram(data = fit_bg, fill="grey", binwidth=.3, alpha=.5) + geom_histogram(colour="black", binwidth=.3) + labs(title = "6.3 Sleep per day", x = "Hours of Sleep", y="") + facet_wrap(~Weekday) + guides(fill=FALSE) + theme_bw() ggplot(fit_rev, aes(x=Minutes.Asleep, fill=Month)) + geom_histogram(colour="black", binwidth=.3) + labs(title = "6.4 Sleep per month", x = "Hours of Sleep", y="") + facet_wrap(~Month) + guides(fill=FALSE) + theme_bw() ggplot(fit_rev, aes(x=Total.Activity, fill=Weekday)) + #geom_histogram(data = fit_bg, fill="grey", binwidth=.3, alpha=.5) + geom_histogram(colour="black", binwidth=.3) + labs(title = "6.5 Activity per day", x = "Hours of Activity", y="") + facet_wrap(~Weekday) + guides(fill=FALSE) + theme_bw() ggplot(fit_rev, aes(x=Total.Activity, fill=Month)) + geom_histogram(colour="black", binwidth=.3) + labs(title = "6.6 Activity per month", x = "Hours of Activity", y="") + facet_wrap(~Month) + guides(fill=FALSE) + theme_bw() ``` *** This is a collection of addtional charts created during the process. 6.1 A look at hours asleep per month. Although we tend to stay away from pie charts, here it is acceptable because instead of using the chart to illustrate the differences between each month, I am using the wedges to show how similar the values are. 6.2 uses geom_hex() to compare hours of sleep to awakenings. 6.3 & 6.4 provide a look at the hours of sleep by day of week and month of activity. ### Summary ```{r} ggplot(fit_rev, aes(Date, Minutes.Asleep, colour=factor(Weekday))) + geom_point(alpha=.1, size = fit_rev$Distance*4) + geom_point(alpha=.4, size = fit_rev$Total.Activity*.7) + labs(x = "Jan 1 - Jul 31", y = "Hours", title = "7 months of sleep data") + theme(legend.position="none", axis.text.x=element_blank(), axis.ticks.x=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank(), panel.grid.major = element_blank()) ``` *** The next step is to test this dashboard by loadling datasets from other users. Althought I chose to use the storyboard version of Flex Dashboard, I believe using Shiny widgets would create a more interactive solution, providing the option for users to select the metrics for comparison. For me, the overall success of this project came from being able to create data visualizations which promote the Quantified Self movement. I learned a tremendous amount about presenting information using ggplot, skills which will help me moving forward as a student, educator, and future data scientist.