forked from info201b-2022-spring/indicators-of-diabetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchart2.R
26 lines (20 loc) · 971 Bytes
/
chart2.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library(dplyr)
library(ggplot2)
data <- read.csv("data/diabetes_012_health_indicators_BRFSS2015.csv", header = TRUE)
diabetes_age <- data %>%
select(Diabetes_012, Age)
plot2 <- ggplot(diabetes_age, aes(x = factor(Diabetes_012), y = Age, fill = factor(Diabetes_012))) +
geom_boxplot(alpha = 0.5) +
scale_fill_brewer(name = "Diabetes Classification", palette = "Paired") +
ggtitle("Age Range Distribution Across Diabetes Cases",
subtitle = "0 indicates no diabetes. 1 indicates pre-diabetes. 2 indicates diabetes") +
xlab("Without Diabetes, Pre-Diabetes, With Diabetes") +
ylab("Age Range")
#diabetes_only <- data[c("Diabetes_012")]
#table_diabetes <- as.data.frame(table(diabetes_only))
# plot2 <- ggplot(diabetes_only, aes(x = Diabetes_012)) +
# geom_bar() +
# gtitle("Quantities of Responses to Diabetes Survey",
# subtitle =
# "0 indicates no diabetes. 1 indicates pre-diabetes. 2 indicates diabetes")
print(plot2)