University is an experience that goes differently for each individual. There are those individuals that spend most of their time studying for exams, while others use that allotted time for various forms of recreation. The one thing that remains constant, and should remain constant is the fact that every student needs their slumber. This study/statistic aims to plot the correlations between personal demographics and hours of sleep.
Up to 60% of all college students suffer from a poor sleep quality, and 7.7% meet all criteria of an insomnia disorders. Sleep problems have a great impact on the students’ daily life, for example, the grade point average. Poor sleep has also been linked to mental health problems such as depression and anxiety.Sleep Problems in University Students
Good sleep is strongly linked to learning, memory, creativity, and problem solving. However, poor sleep habits notoriously plague college and university students, depriving them of performing their best when it matters the most.How University Students Sleep
It’s not far-fetched to assume that most people have experienced a “zombie-like” feeling when they do not get enough sleep. It’s not hard to say that there are people who feel worse throughout the day if they did not catch enough “z’s” the night before. It’s pertinent knowledge that sleep is essential and there are numerous studies highlighting the pros and cons of sleep and lack thereof.
This study, however, is for the university students. As stated earlier, lack of sleep can have a detrimental effect on one’s marks and mental health. And in a pressuring environment such as university, it only makes the problem that much worse. If trends show that students in certain faculties are receiving less sleep, then perhaps students and staff can work together to reduce the study load and ensure the mental wellbeing of those studying is kept in tact.
library(data.table) # for importing dataset
library(corrplot) # correlation analysis
library(tidyverse) # data handling
library(GGally) # better data visialization
library(plotly) # interctive data visualization
library(DT) # datatable
library(stringr) # data cleaning
sleepstudy <- fread("SleepStudyCleaned.csv", data.table = F, stringsAsFactors = TRUE)
names(sleepstudy) <- c("Date", "Gender", "Age", "Nationality", "Degree", "Double_Degree",
"credits_of_semester", "hours_in_class_per_week", "hours_studying_per_day",
"hours_sleeping_per_night")
sleepstudy$Date <- as.character(sleepstudy$Date)
sleepstudy$Date <- sleepstudy$Date %>% str_replace(pattern = "午後", replacement = "PM")
sleepstudy$Date <- sleepstudy$Date %>% str_replace(pattern = "午前", replacement = "AM")
sleepstudy$Date <- as.factor(sleepstudy$Date)sleepstudy %>%
datatable(option =
list(lengthMenu = c(5, 10, 48),
pageLength = 20))This table is a summary of all the data gathered, which can be rearranged to show ascending or descending order.
## 'data.frame': 48 obs. of 10 variables:
## $ Date : Factor w/ 48 levels "2018/04/23 1:55:39 PM GMT+10",..: 1 2 3 5 6 7 8 9 10 11 ...
## $ Gender : Factor w/ 2 levels "Female","Male": 1 1 1 1 1 2 2 1 2 2 ...
## $ Age : int 35 18 18 19 22 21 23 28 21 23 ...
## $ Nationality : Factor w/ 16 levels "Afghan","Australian",..: 2 2 3 1 16 8 9 2 2 2 ...
## $ Degree : Factor w/ 22 levels "Advance Computing & Science",..: 9 9 9 17 19 7 17 17 4 5 ...
## $ Double_Degree : Factor w/ 2 levels "No","Yes": 1 1 1 1 2 1 1 1 1 1 ...
## $ credits_of_semester : int 18 24 24 24 24 24 12 18 24 24 ...
## $ hours_in_class_per_week : int 13 5 17 20 18 10 8 15 6 12 ...
## $ hours_studying_per_day : num 2.5 9 2 3 6 5 1 3 5 3 ...
## $ hours_sleeping_per_night: num 7 7 6 6 6 6 8 8 8 7 ...
sleepstudy %>% ggplot(aes(x = hours_sleeping_per_night)) +
geom_histogram(aes(fill = Gender), binwidth = 1.0) +
geom_vline(xintercept = mean(sleepstudy$hours_sleeping_per_night), linetype="dotted",
color = "blue", size=1.5) +
geom_text(aes(x=mean(sleepstudy$hours_sleeping_per_night), label="Average Sleep Hour", y=10),
colour="blue", angle=90, vjust = -1, text=element_text(size=11)) +
geom_vline(xintercept = 8, linetype="dotted",
color = "red", size=1.5) +
geom_text(aes(x=8, label="Recommended Sleep Hour", y=13),
colour="red", angle=90, vjust = -1, text=element_text(size=11)) +
labs(x = "Sleeping Hour", title = "Sleeping Hour") +
scale_fill_manual(values = c("pink", "skyblue"))According to National Institute of Neurogical Disorders and Stroke, most adults need 8 hours of sleep a night.
corrplot_df <- sleepstudy %>%
select(hours_sleeping_per_night,Age, credits_of_semester,
hours_in_class_per_week, hours_studying_per_day)
corrplot_df <- corrplot_df %>%
mutate(hours_in_class_per_day = hours_in_class_per_week/5)
corrplot_df <- corrplot_df %>% select(-hours_in_class_per_week)
names(corrplot_df) <- c("Sleeping Hour per night", "Age","Credits for semester", "Studying Hour per day", "Hours in class per day")
corrplot(cor(corrplot_df),
method="color",
sig.level = 0.01, insig = "blank",
addCoef.col = "black",
tl.srt=45,
type="upper"
)average_sleepstudy <- sleepstudy %>%
group_by(Degree) %>%
mutate(average_hours_in_class_per_day = mean(hours_in_class_per_week)/5,
average_hours_studying_per_day = mean(hours_studying_per_day),
average_hours_sleeping_per_night = mean(hours_sleeping_per_night)) %>%
select(Date, Gender, Nationality, Degree,contains("average"))barplot <- average_sleepstudy %>%
distinct(Degree, .keep_all = T) %>%
gather("average_hours_sleeping_per_night",
"average_hours_in_class_per_day", "average_hours_studying_per_day",
key = "Type", value = "Time") %>%
ggplot(aes(x = Degree, y = Time, fill = Type)) +
geom_bar(stat="identity",
position=position_dodge2()) +
scale_fill_discrete(
labels=c("Class Hour per Day",
"Sleeping Hour per Day",
"Studying Hour per Day")) +
theme(axis.text.x = element_text(angle = 20, hjust = 1)) +
labs(title = "Average Sleeping, Class and Studying Hour")
ggplotly(barplot) %>%
layout(legend = list(orientation = 'h', y =-1))sleepstudy %>%
ggplot(aes(x = Nationality, y = hours_studying_per_day, fill = Nationality)) +
geom_boxplot(show.legend = FALSE) +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(y = "Hour", title = "Studying Hour / Nationality")