forked from info201b-2022-spring/indicators-of-diabetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable_summary.R
22 lines (16 loc) · 912 Bytes
/
table_summary.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
library(dplyr)
setwd("C:/Users/brand/INFO 201/final-projects-daniellatsing/data")
diabetes_df <- read.csv("diabetes_012_health_indicators_BRFSS2015.csv")
#diabetes_df <- read.csv("/Users/daniella/desktop/INFO 201/final-projects-daniellatsing/data/diabetes_012_health_indicators_BRFSS2015.csv")
summary_table <- group_by(diabetes_df, Diabetes_012) %>%
summarise(numRespondants = length(Diabetes_012),
meanAge = mean(Age),
meanBMI = mean(BMI), meanIncome = mean(Income),
highCholesterol = sum(HighChol), highBP = sum(HighBP),
Avg.Days.Poor.Phys.Health = mean(PhysHlth),
Avg.Days.Poor.Mental.Health = mean(MentHlth)) %>%
round(digits = 0)
summary_table$Diabetes_012[1] <- "No Diabetes"
summary_table$Diabetes_012[2] <- "Pre-Diabetes"
summary_table$Diabetes_012[3] <- "Diabetes"
colnames(summary_table)[1] <- "Diabetes Classification"