-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualize2.R
More file actions
51 lines (39 loc) · 1.31 KB
/
Copy pathvisualize2.R
File metadata and controls
51 lines (39 loc) · 1.31 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
library(tidyverse)
df <- read.csv("healthcare-dataset-stroke-data.csv")
df %>%
group_by(gender) %>%
filter(bmi != "N/A",gender != "Other") %>%
mutate(hypertension = factor(ifelse(hypertension == 1, "yes", "no")),
heart_disease = factor(ifelse(heart_disease == 1, "yes", "no")),
stroke = factor(ifelse(stroke == 1, "yes", "no")),
bmi = as.double(bmi)) %>%
mutate_if(is.character, as.factor) -> stroke_mod
summary(stroke_mod)
#gender
ggplot(stroke_mod,aes(gender,fill = stroke)) +
geom_bar() +
labs(title = "Gender:stroke")
#hypertension
ggplot(stroke_mod,aes(hypertension,fill = stroke))+
geom_bar()+
labs(title = "Hypertension:stroke")
#heart disease
ggplot(stroke_mod,aes(heart_disease,fill = stroke))+
geom_bar()+
labs(title = "Heart disease:stroke")
#married
ggplot(stroke_mod,aes(ever_married,fill = stroke))+
geom_bar()+
labs(title = "Ever-married:stroke")
#work-type
ggplot(stroke_mod,aes(work_type,fill = stroke))+
geom_bar() +
labs(title = "Hypertension:stroke")
#residence
ggplot(stroke_mod,aes(Residence_type,fill = stroke))+
geom_bar()+
labs(title = "Residence:stroke")
#smoking status
ggplot(stroke_mod,aes(smoking_status,fill = stroke))+
geom_bar()+
labs(title = "Smoking status:stroke")