Background: I checked my daily sleep stats including in bed time, time in bed (hours), deep sleep times, awake times and sleep quality using an app called ‘Sleep Cycle’. In this study, I want to see how my sleep scores varies, what are the factors impact my sleep score.

  1. What is the mean of my sleep score?
library(readxl)
Sleep <- read_excel("C:/Users/Maple/Desktop/HU/Second sem/Data Visualization/Sleep_stats.xlsx")
## readxl works best with a newer version of the tibble package.
## You currently have tibble v1.4.2.
## Falling back to column name repair from tibble <= v1.4.2.
## Message displays once per session.
View(Sleep)

mean(Sleep$Sleep_Quality)
## [1] 78.3125

2.What is the standard deviation of my sleep score

sd(Sleep$Sleep_Quality)
## [1] 8.332417
  1. How is my sleep score distributed?
barplot(Sleep$Sleep_Quality, main = "Sleep Score", col = "blue")

boxplot(Sleep$Sleep_Quality, main = "Sleep Score", col = "yellow")

  1. What is the relationship between sleep score and weekday, In bed time, Time in Bed, Deep Sleep and Awake Time?
library(readxl)
Sleep <- read_excel("C:/Users/Maple/Desktop/HU/Second sem/Data Visualization/Sleep_stats.xlsx")
Cor <- cor(Sleep,use="pairwise", method="pearson")
library(corrplot)
## corrplot 0.84 loaded
corrplot(Cor)

  1. How do in bed time, time in bed, deep sleep times, awake times impact sleep quality?
library(readxl)
Sleep <- read_excel("C:/Users/Maple/Desktop/HU/Second sem/Data Visualization/Sleep_stats.xlsx")
lm(formula=Sleep_Quality ~ In_bed_time+Time_in_Bed+Deep_Sleep+Awake_Time,data = Sleep)
## 
## Call:
## lm(formula = Sleep_Quality ~ In_bed_time + Time_in_Bed + Deep_Sleep + 
##     Awake_Time, data = Sleep)
## 
## Coefficients:
## (Intercept)  In_bed_time  Time_in_Bed   Deep_Sleep   Awake_Time  
##      56.452       -2.794        4.802       -1.168       -4.787
  1. Is the model reliabe?
plot(lm(formula=Sleep_Quality ~ In_bed_time+Time_in_Bed+Deep_Sleep+Awake_Time,data = Sleep))