Importing data
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.6.2
##
## 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(readr)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.6.2
data<-read_csv("/Users/rebeccagibble/Downloads/SD4 NHIS Data.csv")
## Parsed with column specification:
## cols(
## health = col_double(),
## sex = col_double(),
## bmi = col_double()
## )
head(data)
## # A tibble: 6 x 3
## health sex bmi
## <dbl> <dbl> <dbl>
## 1 3 1 33.4
## 2 1 2 20.2
## 3 3 1 27.3
## 4 3 2 38.6
## 5 1 2 40.0
## 6 2 2 18.8
Percentage of Respondents in each Health Status Category
data2<-data1%>%
select(HealthStatus)%>%
na.exclude()
table(data2$HealthStatus)%>%
prop.table()%>%
round(2)
##
## Excellent Fair Good Poor Very Good
## 0.25 0.11 0.27 0.03 0.34
Percentage of Repsondents per sex
data3<-data1%>%
select(MaleOrFemale)%>%
na.exclude()
table(data3$MaleOrFemale)%>%
prop.table()%>%
round(2)
##
## Female Male
## 0.55 0.45
Mean BMI
data4<-data1%>%
select(BodyMassIndex)%>%
summarize(Avg_BodyMassIndex = mean(BodyMassIndex,na.rm=TRUE))
print(data4)
## # A tibble: 1 x 1
## Avg_BodyMassIndex
## <dbl>
## 1 28.0