setwd("C:/akong project/")
load("brfss2013.RData")
library("magrittr")
## Warning: package 'magrittr' was built under R version 4.0.5
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
library("ggplot2")

What are its statistics using the fucntionsummary in R?

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
Whout_sleptim1<-brfss2013%>%
  filter(!is.na(sleptim1))
  summary(Whout_sleptim1$sleptim1)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.000   6.000   7.000   7.052   8.000 450.000
summary(brfss2013$addepev2)
##    Yes     No   NA's 
##  95779 393707   2289

provide statistics using the function summary without summary without NA's and data with at most 10h hours of sleep.

y<- na.omit(brfss2013$addepev2)
summary(y)
##    Yes     No 
##  95779 393707
ten<- Whout_sleptim1%>%
  filter(!sleptim1<11)
  summary(ten$sleptim1)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   11.00   12.00   12.00   12.92   13.00  450.00

research 2

sl_dep5 <- Whout_sleptim1%>%
  filter(!is.na(sleptim1),!is.na(addepev2),sleptim1<6)%>%
  group_by(addepev2)%>%
  summarise(count=n())
sl_dep5
## # A tibble: 2 x 2
##   addepev2 count
##   <fct>    <int>
## 1 Yes      17828
## 2 No       34275

The means that 34.21% are those having depression as perceived by others having lessthan 6 hours of sleep.

ggplot(data=sl_dep5,aes(x=addepev2,y=count))+geom_bar(stat="identity",color='red',fill='orange')+xlab("Depressive Disorder for people having at most 5 hours of average sleep")+ylab("Number of US citizens ")

(17828/(17828+34275))
## [1] 0.3421684

research3

sl_dep6 <- ten %>%
  filter(!is.na(sleptim1),!is.na(addepev2),sleptim1>5)%>%
  group_by(addepev2)%>%
  summarise(count=n())
sl_dep6
## # A tibble: 2 x 2
##   addepev2 count
##   <fct>    <int>
## 1 Yes       2266
## 2 No        3910
ggplot(data=sl_dep6,aes(x=addepev2,y=count))+geom_bar(stat="identity",color='red',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

This shows that the average sleep range from 6 to 10 hours have lower depression disorderas percieved by other and thus lower depression disorder.