-
Notifications
You must be signed in to change notification settings - Fork 0
/
question.R
71 lines (60 loc) · 2.44 KB
/
question.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
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Dr=getwd()
setwd(Dr)
# loading the data
data<-read.csv("heart_failure_clinical_records_dataset .csv")
# Summary of the data
summary(data)
#Question-1
#Subset of people_with_diabetes
people_with_diabetes <- subset(data , diabetes=='1')
people_with_diabetes
#create a table of patients with diabetes and high blood pressure only
table(people_with_diabetes$diabetes,people_with_diabetes$high_blood_pressure) -> temp_table
temp_table
#Draw a bar plot of table
barplot(temp_table , legend=T , beside = T ,xlab = "Diabetes_Patient",ylab = "Number_Of_Pateints")
ch_test <- chisq.test(temp_table,correct=FALSE)
ch_test$expected
ch_test$observed
# Question-2
#Subset of people_with_anemia
people_with_anemia <- subset(data , anaemia=='1')
people_with_anemia
#create a table of patients with anemia with gender
table(people_with_anemia$anaemia,people_with_anemia$sex) -> temp_table
temp_table
#Draw a bar plot of table
barplot(temp_table , beside = T ,xlab = "Gender",ylab = "Pateints_Having_Anemia")
ch_test <- chisq.test(temp_table,correct=FALSE)
ch_test$expected
ch_test$observed
# Question-3
#Subset of people_with_specific_age
people_with_specific_age <-subset(data , data$age >=55 & data$age <= 65)
people_with_specific_age
#Subset of people_with_blood_pressure
people_with_blood_pressure <- subset(people_with_specific_age, high_blood_pressure=="1")
people_with_blood_pressure
#create a table of patients with blood pressure and there survival or not
table(people_with_blood_pressure$high_blood_pressure,people_with_blood_pressure$DEATH_EVENT) -> temp_table
temp_table
#Draw a bar plot of table
barplot(temp_table , beside = T ,xlab = "DEATH_EVENT",ylab = "Pateints_Having_High_Blood_Pressure")
ch_test <- chisq.test(temp_table,correct=FALSE)
ch_test$expected
ch_test$observed
# Question-4
#Subset of people_with_specific_age
people_with_diabetes <- subset(data , data$diabetes=="1")
people_with_diabetes
#Subset of people_with_smoking
people_with_smoking <- subset(people_with_diabetes , people_with_diabetes$smoking=="1")
people_with_smoking
#create a table of patients with blood pressure and there survival or not
table(people_with_smoking$smoking,people_with_smoking$DEATH_EVENT) -> temp_table
temp_table
#Draw a bar plot of table
barplot(temp_table , beside = T ,xlab = "DEATH_EVENT",ylab = "people_with_smoking")
ch_test <- chisq.test(temp_table,correct=FALSE)
ch_test$expected
ch_test$observed