First, let us prepare and load the packages and data needed
library(ggplot2)
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.0.4
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
load("brfss2013.RData")
Research Problems:
Exploratory Data Analysis and some statistics on the variables “sleptim1” and “addepev2” in terms of the following:
1.1 What are its statistics using the function summary in R?
Using the function summary in R on the observations of the variable “sleptim1”
summary(brfss2013$sleptim1)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 0.000 6.000 7.000 7.052 8.000 450.000 7387
Using the function summary in R on the observations of the variable “addepev2”
summary(brfss2013$addepev2)
## Yes No NA's
## 95779 393707 2289
1.2 Provide statistics using the function summary without NA’s and data with at most 10 hours of sleep.
Using the function summary in R on the observations of the variable “sleptim1” excluding NA’s
Sur<-brfss2013%>%
filter(!is.na(sleptim1))
summary(Sur$sleptim1)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 6.000 7.000 7.052 8.000 450.000
Using the function summary in R on the observations of the variable “sleptim1” for atmost 10 hours of sleep
igao<-brfss2013%>%
filter(sleptim1<=10)
summary(igao$sleptim1)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 6.000 7.000 6.976 8.000 10.000
The outputs above show that all three results give the same results except for the Maximum. This tells us that there are only few observations having beyond 10 hours of sleep on the average.
Research question 2: What analysis can you share on the Perception of others to the Depressive Disorder of the Respondents with those having less than 6 hours of sleep on average?
Surigao<-Sur%>%
filter(!is.na(sleptim1),!is.na(addepev2),sleptim1<6)%>%
group_by(addepev2)%>%
summarise(count=n())
Surigao
## # A tibble: 2 x 2
## addepev2 count
## <fct> <int>
## 1 Yes 17828
## 2 No 34275
ggplot(data=Surigao,aes(x=addepev2,y=count))+geom_bar(stat="identity",color='orange',fill='red')+xlab("Depressive Disorder for people having less than 6 hours average sleep")+ylab("Number of US citizens ")
(17828/(17828+34275))
## [1] 0.3421684
The above results tell us that those having depression disorder as perceived others having less than 6 hours of sleep on the average is about 34.23%. This means that of those who sleep less than 6 hours on the average, 1 out of 3 is perceived by others having depression disorder.
Research question 3: What insights can you provide in comparing between having less than 6 hours of sleep and having 6 to 10 hours of sleep that were perceived with depression disorder (addepev2)?
SurigaoNorte<-igao%>%
filter(!is.na(sleptim1),!is.na(addepev2),sleptim1>5)%>%
group_by(addepev2)%>%
summarise(count=n())
SurigaoNorte
## # A tibble: 2 x 2
## addepev2 count
## <fct> <int>
## 1 Yes 73771
## 2 No 350259
ggplot(data=SurigaoNorte,aes(x=addepev2,y=count))+geom_bar(stat="identity",color='orange',fill='blue')+xlab("Depressive Disorder for people having 6 to 10 hours average sleep")+ylab("Number of US citizens ")
(73771/(73771+350259))
## [1] 0.1739759
Based on the results of research question 2 and with the result of research Question 3, it shows that those having 6 to 10 hours of average sleep have lower depression disorder as perceived by others which accounts to 17.40% than those having less than 6 hours of sleep which is 34.2%. This tells us that having 6 to 10 hours of average sleep would lower depression disorder as perceived by others.