-
Notifications
You must be signed in to change notification settings - Fork 0
/
day 7.R
134 lines (96 loc) · 2.54 KB
/
day 7.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
library("readr")
path <- "C:/Users/USER/Desktop/Data 1/diabetes.csv"
df <- read_csv(path)
View(df)
cols <- colnames(df)
print(cols)
print(nrow(df))
print(ncol(df))
a_val <- df$Age >=50
b_val <- df[a_val,]
sum(a_val)
d_val <- which(a_val)
print(d_val)
print(df[d_val,])
age_dependency <- function(age_val){
a_val <- df$Age >=age_val
b_val <- df[a_val,]
print(b_val)
}
age_dependency(25)
age_outcome_dependency <- function(age, outcome_val){
age_outcome <- df$Age > age & df$Outcome == outcome_val
a_out <- df[age_outcome, ]
print(a_out)
}
age_outcome_dependency(38, 1)
a.mean_val <- function(out_val){
mean_out_a <- df$Outcome == out_val
df_out <- df[mean_out_a, ]
ped <- mean(df_out$DiabetesPedigreeFunction)
value<- paste("the mean of outcome ", out_val, "pedigree function", ped, sep = " ")
return(value)
}
zero_out <- a.mean_val(0)
print(zero_out)
one_out <- a.mean_val(1)
print(one_out)
mean_out_a <- df$Outcome == 1
df_out <- df[mean_out_a, ]
View(df_out)
ped <- mean(df_out$DiabetesPedigreeFunction)
print(ped)
#value<- paste("the mean of outcome ", out_val, "pedigree function", ped, sep = " ")
unique_age_val <- unique(df$Age)
bp_mean <- c()
for (i in unique_age_val){
bp <- df$Age == i
df_age <- df[bp, ]
mean_bp <- mean(df_age$BloodPressure)
bp_mean <- c(bp_mean, mean_bp)
}
print(bp_mean)
new_bp_mean <- data.frame(
age_val = unique_age_val,
mean_BP = bp_mean
)
print(new_bp_mean)
max_bp <- min(new_bp_mean$mean_BP)
a <- new_bp_mean$mean_BP == max_bp
new_bp_mean[a, ]
#print(unique_age_val)
mean_out_a <- df$Outcome == 1
df_out <- df[mean_out_a, ]
View(df_out)
ped <- mean(df_out$DiabetesPedigreeFunction)
print(ped)
#value<- paste("the mean of outcome ", out_val, "pedigree function", ped, sep = " ")
unique_age_val <- unique(df$Age)
bp_mean <- c()
for (i in unique_age_val){
bp <- df$Age == i
df_age <- df[bp, ]
mean_bp <- sum(df_age$BloodPressure)
bp_mean <- c(bp_mean, mean_bp)
}
print(bp_mean)
new_bp_mean <- data.frame(
age_val = unique_age_val,
mean_BP = bp_mean
)
print(new_bp_mean)
max_bp <- min(new_bp_mean$mean_BP)
a <- new_bp_mean$mean_BP == max_bp
new_bp_mean[a, ]
vals <- df$BloodPressure
bp_percent <- c()
for (i in vals){
percent_bp <- round((i/ sum(df$BloodPressure))* 100, 3)
bp_percent <- c(bp_percent, percent_bp)
}
data_percent <- data.frame(
bloodpressure = vals,
perecntage = bp_percent
)
print(data_percent)
View(data_percent)