library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(MASS)
##
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
##
## select
data("survey")
head(survey)
## Sex Wr.Hnd NW.Hnd W.Hnd Fold Pulse Clap Exer Smoke Height M.I
## 1 Female 18.5 18.0 Right R on L 92 Left Some Never 173.00 Metric
## 2 Male 19.5 20.5 Left R on L 104 Left None Regul 177.80 Imperial
## 3 Male 18.0 13.3 Right L on R 87 Neither None Occas NA <NA>
## 4 Male 18.8 18.9 Right R on L NA Neither None Never 160.00 Metric
## 5 Male 20.0 20.0 Right Neither 35 Right Some Never 165.00 Metric
## 6 Female 18.0 17.7 Right L on R 64 Right Some Never 172.72 Imperial
## Age
## 1 18.250
## 2 17.583
## 3 16.917
## 4 20.333
## 5 23.667
## 6 21.000
names(survey)
## [1] "Sex" "Wr.Hnd" "NW.Hnd" "W.Hnd" "Fold" "Pulse" "Clap" "Exer"
## [9] "Smoke" "Height" "M.I" "Age"
veri1 <-survey %>% dplyr::select(Sex, Age, Pulse, Exer, Height, Smoke)
head(veri1)
## Sex Age Pulse Exer Height Smoke
## 1 Female 18.250 92 Some 173.00 Never
## 2 Male 17.583 104 None 177.80 Regul
## 3 Male 16.917 87 None NA Occas
## 4 Male 20.333 NA None 160.00 Never
## 5 Male 23.667 35 Some 165.00 Never
## 6 Female 21.000 64 Some 172.72 Never
veri2<-veri1 %>% rename(cinsiyet=Sex, yas=Age, boy=Height,sigara= Smoke,egzersiz=Exer,nabiz=Pulse)
head(veri2)
## cinsiyet yas nabiz egzersiz boy sigara
## 1 Female 18.250 92 Some 173.00 Never
## 2 Male 17.583 104 None 177.80 Regul
## 3 Male 16.917 87 None NA Occas
## 4 Male 20.333 NA None 160.00 Never
## 5 Male 23.667 35 Some 165.00 Never
## 6 Female 21.000 64 Some 172.72 Never
names(veri2)
## [1] "cinsiyet" "yas" "nabiz" "egzersiz" "boy" "sigara"
veri3<-veri2 %>%
mutate(cinsiyet= recode(cinsiyet, "Female"= "Kadın","Male"= "Erkek"),
egzersiz=recode(egzersiz,
"None"="Yok",
"Some"="Bazen",
"Freq"="Sık"),
sigara= recode(sigara,
"Never"= "Hiç",
"Occas"="Ara Sıra",
"Regul"="Düzenli",
"Heavy"="Fazla"))
head (veri3)
## cinsiyet yas nabiz egzersiz boy sigara
## 1 Kadın 18.250 92 Bazen 173.00 Hiç
## 2 Erkek 17.583 104 Yok 177.80 Düzenli
## 3 Erkek 16.917 87 Yok NA Ara Sıra
## 4 Erkek 20.333 NA Yok 160.00 Hiç
## 5 Erkek 23.667 35 Bazen 165.00 Hiç
## 6 Kadın 21.000 64 Bazen 172.72 Hiç
is.na(veri3)
## cinsiyet yas nabiz egzersiz boy sigara
## 1 FALSE FALSE FALSE FALSE FALSE FALSE
## 2 FALSE FALSE FALSE FALSE FALSE FALSE
## 3 FALSE FALSE FALSE FALSE TRUE FALSE
## 4 FALSE FALSE TRUE FALSE FALSE FALSE
## 5 FALSE FALSE FALSE FALSE FALSE FALSE
## 6 FALSE FALSE FALSE FALSE FALSE FALSE
## 7 FALSE FALSE FALSE FALSE FALSE FALSE
## 8 FALSE FALSE FALSE FALSE FALSE FALSE
## 9 FALSE FALSE FALSE FALSE FALSE FALSE
## 10 FALSE FALSE FALSE FALSE FALSE FALSE
## 11 FALSE FALSE FALSE FALSE FALSE FALSE
## 12 FALSE FALSE FALSE FALSE TRUE FALSE
## 13 FALSE FALSE TRUE FALSE FALSE FALSE
## 14 FALSE FALSE FALSE FALSE FALSE FALSE
## 15 FALSE FALSE FALSE FALSE TRUE FALSE
## 16 FALSE FALSE TRUE FALSE FALSE FALSE
## 17 FALSE FALSE FALSE FALSE FALSE FALSE
## 18 FALSE FALSE FALSE FALSE FALSE FALSE
## 19 FALSE FALSE TRUE FALSE FALSE FALSE
## 20 FALSE FALSE FALSE FALSE FALSE FALSE
## 21 FALSE FALSE FALSE FALSE FALSE FALSE
## 22 FALSE FALSE FALSE FALSE FALSE FALSE
## 23 FALSE FALSE FALSE FALSE FALSE FALSE
## 24 FALSE FALSE FALSE FALSE FALSE FALSE
## 25 FALSE FALSE FALSE FALSE TRUE FALSE
## 26 FALSE FALSE FALSE FALSE TRUE FALSE
## 27 FALSE FALSE FALSE FALSE FALSE FALSE
## 28 FALSE FALSE FALSE FALSE FALSE FALSE
## 29 FALSE FALSE FALSE FALSE TRUE FALSE
## 30 FALSE FALSE FALSE FALSE FALSE FALSE
## 31 FALSE FALSE FALSE FALSE TRUE FALSE
## 32 FALSE FALSE FALSE FALSE FALSE FALSE
## 33 FALSE FALSE FALSE FALSE FALSE FALSE
## 34 FALSE FALSE FALSE FALSE FALSE FALSE
## 35 FALSE FALSE FALSE FALSE TRUE FALSE
## 36 FALSE FALSE FALSE FALSE FALSE FALSE
## 37 FALSE FALSE TRUE FALSE FALSE FALSE
## 38 FALSE FALSE FALSE FALSE FALSE FALSE
## 39 FALSE FALSE FALSE FALSE FALSE FALSE
## 40 FALSE FALSE TRUE FALSE FALSE FALSE
## 41 FALSE FALSE TRUE FALSE FALSE FALSE
## 42 FALSE FALSE FALSE FALSE FALSE FALSE
## 43 FALSE FALSE FALSE FALSE FALSE FALSE
## 44 FALSE FALSE FALSE FALSE FALSE FALSE
## 45 FALSE FALSE FALSE FALSE FALSE FALSE
## 46 FALSE FALSE TRUE FALSE FALSE FALSE
## 47 FALSE FALSE FALSE FALSE FALSE FALSE
## 48 FALSE FALSE FALSE FALSE FALSE FALSE
## 49 FALSE FALSE FALSE FALSE FALSE FALSE
## 50 FALSE FALSE FALSE FALSE FALSE FALSE
## 51 FALSE FALSE FALSE FALSE FALSE FALSE
## 52 FALSE FALSE FALSE FALSE FALSE FALSE
## 53 FALSE FALSE FALSE FALSE FALSE FALSE
## 54 FALSE FALSE FALSE FALSE FALSE FALSE
## 55 FALSE FALSE FALSE FALSE FALSE FALSE
## 56 FALSE FALSE TRUE FALSE FALSE FALSE
## 57 FALSE FALSE FALSE FALSE FALSE FALSE
## 58 FALSE FALSE FALSE FALSE TRUE FALSE
## 59 FALSE FALSE FALSE FALSE FALSE FALSE
## 60 FALSE FALSE TRUE FALSE FALSE FALSE
## 61 FALSE FALSE FALSE FALSE FALSE FALSE
## 62 FALSE FALSE FALSE FALSE FALSE FALSE
## 63 FALSE FALSE FALSE FALSE FALSE FALSE
## 64 FALSE FALSE TRUE FALSE FALSE FALSE
## 65 FALSE FALSE FALSE FALSE FALSE FALSE
## 66 FALSE FALSE TRUE FALSE FALSE FALSE
## 67 FALSE FALSE TRUE FALSE FALSE FALSE
## 68 FALSE FALSE FALSE FALSE TRUE FALSE
## 69 FALSE FALSE TRUE FALSE FALSE FALSE
## 70 FALSE FALSE FALSE FALSE TRUE TRUE
## 71 FALSE FALSE FALSE FALSE FALSE FALSE
## 72 FALSE FALSE TRUE FALSE FALSE FALSE
## 73 FALSE FALSE FALSE FALSE FALSE FALSE
## 74 FALSE FALSE FALSE FALSE FALSE FALSE
## 75 FALSE FALSE FALSE FALSE FALSE FALSE
## 76 FALSE FALSE FALSE FALSE FALSE FALSE
## 77 FALSE FALSE FALSE FALSE FALSE FALSE
## 78 FALSE FALSE TRUE FALSE FALSE FALSE
## 79 FALSE FALSE FALSE FALSE FALSE FALSE
## 80 FALSE FALSE TRUE FALSE FALSE FALSE
## 81 FALSE FALSE FALSE FALSE TRUE FALSE
## 82 FALSE FALSE FALSE FALSE FALSE FALSE
## 83 FALSE FALSE FALSE FALSE TRUE FALSE
## 84 FALSE FALSE TRUE FALSE TRUE FALSE
## 85 FALSE FALSE FALSE FALSE FALSE FALSE
## 86 FALSE FALSE FALSE FALSE FALSE FALSE
## 87 FALSE FALSE FALSE FALSE FALSE FALSE
## 88 FALSE FALSE FALSE FALSE FALSE FALSE
## 89 FALSE FALSE FALSE FALSE FALSE FALSE
## 90 FALSE FALSE FALSE FALSE TRUE FALSE
## 91 FALSE FALSE FALSE FALSE FALSE FALSE
## 92 FALSE FALSE TRUE FALSE TRUE FALSE
## 93 FALSE FALSE FALSE FALSE FALSE FALSE
## 94 FALSE FALSE TRUE FALSE FALSE FALSE
## 95 FALSE FALSE FALSE FALSE FALSE FALSE
## 96 FALSE FALSE TRUE FALSE TRUE FALSE
## 97 FALSE FALSE FALSE FALSE FALSE FALSE
## 98 FALSE FALSE FALSE FALSE FALSE FALSE
## 99 FALSE FALSE TRUE FALSE FALSE FALSE
## 100 FALSE FALSE FALSE FALSE FALSE FALSE
## 101 FALSE FALSE TRUE FALSE FALSE FALSE
## 102 FALSE FALSE FALSE FALSE FALSE FALSE
## 103 FALSE FALSE TRUE FALSE FALSE FALSE
## 104 FALSE FALSE FALSE FALSE FALSE FALSE
## 105 FALSE FALSE FALSE FALSE FALSE FALSE
## 106 FALSE FALSE FALSE FALSE FALSE FALSE
## 107 FALSE FALSE TRUE FALSE FALSE FALSE
## 108 FALSE FALSE FALSE FALSE TRUE FALSE
## 109 FALSE FALSE FALSE FALSE FALSE FALSE
## 110 FALSE FALSE FALSE FALSE FALSE FALSE
## 111 FALSE FALSE FALSE FALSE FALSE FALSE
## 112 FALSE FALSE FALSE FALSE FALSE FALSE
## 113 FALSE FALSE FALSE FALSE FALSE FALSE
## 114 FALSE FALSE FALSE FALSE FALSE FALSE
## 115 FALSE FALSE FALSE FALSE FALSE FALSE
## 116 FALSE FALSE FALSE FALSE FALSE FALSE
## 117 FALSE FALSE FALSE FALSE FALSE FALSE
## 118 FALSE FALSE FALSE FALSE FALSE FALSE
## 119 FALSE FALSE FALSE FALSE FALSE FALSE
## 120 FALSE FALSE FALSE FALSE FALSE FALSE
## 121 FALSE FALSE FALSE FALSE TRUE FALSE
## 122 FALSE FALSE FALSE FALSE FALSE FALSE
## 123 FALSE FALSE FALSE FALSE FALSE FALSE
## 124 FALSE FALSE FALSE FALSE FALSE FALSE
## 125 FALSE FALSE FALSE FALSE FALSE FALSE
## 126 FALSE FALSE TRUE FALSE FALSE FALSE
## 127 FALSE FALSE FALSE FALSE FALSE FALSE
## 128 FALSE FALSE FALSE FALSE FALSE FALSE
## 129 FALSE FALSE FALSE FALSE FALSE FALSE
## 130 FALSE FALSE FALSE FALSE FALSE FALSE
## 131 FALSE FALSE FALSE FALSE FALSE FALSE
## 132 FALSE FALSE FALSE FALSE FALSE FALSE
## 133 FALSE FALSE FALSE FALSE TRUE FALSE
## 134 FALSE FALSE FALSE FALSE FALSE FALSE
## 135 FALSE FALSE FALSE FALSE FALSE FALSE
## 136 FALSE FALSE FALSE FALSE FALSE FALSE
## 137 TRUE FALSE FALSE FALSE FALSE FALSE
## 138 FALSE FALSE FALSE FALSE FALSE FALSE
## 139 FALSE FALSE TRUE FALSE FALSE FALSE
## 140 FALSE FALSE FALSE FALSE FALSE FALSE
## 141 FALSE FALSE FALSE FALSE FALSE FALSE
## 142 FALSE FALSE TRUE FALSE FALSE FALSE
## 143 FALSE FALSE FALSE FALSE FALSE FALSE
## 144 FALSE FALSE FALSE FALSE FALSE FALSE
## 145 FALSE FALSE FALSE FALSE FALSE FALSE
## 146 FALSE FALSE FALSE FALSE FALSE FALSE
## 147 FALSE FALSE FALSE FALSE FALSE FALSE
## 148 FALSE FALSE FALSE FALSE FALSE FALSE
## 149 FALSE FALSE FALSE FALSE FALSE FALSE
## 150 FALSE FALSE FALSE FALSE FALSE FALSE
## 151 FALSE FALSE FALSE FALSE FALSE FALSE
## 152 FALSE FALSE FALSE FALSE FALSE FALSE
## 153 FALSE FALSE FALSE FALSE FALSE FALSE
## 154 FALSE FALSE FALSE FALSE FALSE FALSE
## 155 FALSE FALSE FALSE FALSE FALSE FALSE
## 156 FALSE FALSE FALSE FALSE FALSE FALSE
## 157 FALSE FALSE TRUE FALSE TRUE FALSE
## 158 FALSE FALSE FALSE FALSE FALSE FALSE
## 159 FALSE FALSE TRUE FALSE FALSE FALSE
## 160 FALSE FALSE FALSE FALSE FALSE FALSE
## 161 FALSE FALSE FALSE FALSE FALSE FALSE
## 162 FALSE FALSE TRUE FALSE FALSE FALSE
## 163 FALSE FALSE FALSE FALSE FALSE FALSE
## 164 FALSE FALSE FALSE FALSE FALSE FALSE
## 165 FALSE FALSE TRUE FALSE FALSE FALSE
## 166 FALSE FALSE FALSE FALSE FALSE FALSE
## 167 FALSE FALSE FALSE FALSE FALSE FALSE
## 168 FALSE FALSE FALSE FALSE FALSE FALSE
## 169 FALSE FALSE TRUE FALSE FALSE FALSE
## 170 FALSE FALSE FALSE FALSE FALSE FALSE
## 171 FALSE FALSE TRUE FALSE FALSE FALSE
## 172 FALSE FALSE FALSE FALSE FALSE FALSE
## 173 FALSE FALSE FALSE FALSE TRUE FALSE
## 174 FALSE FALSE FALSE FALSE FALSE FALSE
## 175 FALSE FALSE FALSE FALSE FALSE FALSE
## 176 FALSE FALSE FALSE FALSE FALSE FALSE
## 177 FALSE FALSE FALSE FALSE FALSE FALSE
## 178 FALSE FALSE FALSE FALSE FALSE FALSE
## 179 FALSE FALSE TRUE FALSE TRUE FALSE
## 180 FALSE FALSE FALSE FALSE FALSE FALSE
## 181 FALSE FALSE FALSE FALSE FALSE FALSE
## 182 FALSE FALSE FALSE FALSE FALSE FALSE
## 183 FALSE FALSE FALSE FALSE FALSE FALSE
## 184 FALSE FALSE FALSE FALSE FALSE FALSE
## 185 FALSE FALSE FALSE FALSE FALSE FALSE
## 186 FALSE FALSE FALSE FALSE FALSE FALSE
## 187 FALSE FALSE FALSE FALSE FALSE FALSE
## 188 FALSE FALSE FALSE FALSE FALSE FALSE
## 189 FALSE FALSE FALSE FALSE FALSE FALSE
## 190 FALSE FALSE FALSE FALSE FALSE FALSE
## 191 FALSE FALSE FALSE FALSE FALSE FALSE
## 192 FALSE FALSE FALSE FALSE FALSE FALSE
## 193 FALSE FALSE FALSE FALSE FALSE FALSE
## 194 FALSE FALSE FALSE FALSE FALSE FALSE
## 195 FALSE FALSE TRUE FALSE FALSE FALSE
## 196 FALSE FALSE FALSE FALSE FALSE FALSE
## 197 FALSE FALSE FALSE FALSE FALSE FALSE
## 198 FALSE FALSE FALSE FALSE FALSE FALSE
## 199 FALSE FALSE FALSE FALSE FALSE FALSE
## 200 FALSE FALSE FALSE FALSE FALSE FALSE
## 201 FALSE FALSE FALSE FALSE FALSE FALSE
## 202 FALSE FALSE FALSE FALSE FALSE FALSE
## 203 FALSE FALSE FALSE FALSE TRUE FALSE
## 204 FALSE FALSE FALSE FALSE FALSE FALSE
## 205 FALSE FALSE FALSE FALSE FALSE FALSE
## 206 FALSE FALSE FALSE FALSE FALSE FALSE
## 207 FALSE FALSE FALSE FALSE FALSE FALSE
## 208 FALSE FALSE FALSE FALSE FALSE FALSE
## 209 FALSE FALSE FALSE FALSE FALSE FALSE
## 210 FALSE FALSE TRUE FALSE FALSE FALSE
## 211 FALSE FALSE FALSE FALSE FALSE FALSE
## 212 FALSE FALSE FALSE FALSE FALSE FALSE
## 213 FALSE FALSE FALSE FALSE TRUE FALSE
## 214 FALSE FALSE FALSE FALSE FALSE FALSE
## 215 FALSE FALSE FALSE FALSE FALSE FALSE
## 216 FALSE FALSE TRUE FALSE FALSE FALSE
## 217 FALSE FALSE TRUE FALSE TRUE FALSE
## 218 FALSE FALSE FALSE FALSE FALSE FALSE
## 219 FALSE FALSE TRUE FALSE FALSE FALSE
## 220 FALSE FALSE FALSE FALSE FALSE FALSE
## 221 FALSE FALSE TRUE FALSE FALSE FALSE
## 222 FALSE FALSE FALSE FALSE FALSE FALSE
## 223 FALSE FALSE FALSE FALSE FALSE FALSE
## 224 FALSE FALSE TRUE FALSE FALSE FALSE
## 225 FALSE FALSE TRUE FALSE TRUE FALSE
## 226 FALSE FALSE FALSE FALSE TRUE FALSE
## 227 FALSE FALSE FALSE FALSE FALSE FALSE
## 228 FALSE FALSE FALSE FALSE FALSE FALSE
## 229 FALSE FALSE FALSE FALSE FALSE FALSE
## 230 FALSE FALSE FALSE FALSE FALSE FALSE
## 231 FALSE FALSE FALSE FALSE FALSE FALSE
## 232 FALSE FALSE TRUE FALSE FALSE FALSE
## 233 FALSE FALSE FALSE FALSE FALSE FALSE
## 234 FALSE FALSE FALSE FALSE FALSE FALSE
## 235 FALSE FALSE TRUE FALSE FALSE FALSE
## 236 FALSE FALSE FALSE FALSE FALSE FALSE
## 237 FALSE FALSE FALSE FALSE FALSE FALSE
any(is.na(veri3))
## [1] TRUE
colSums(is.na(veri3))
## cinsiyet yas nabiz egzersiz boy sigara
## 1 0 45 0 28 1
veri_son<- na.omit(veri3)
summary(veri_son)
## cinsiyet yas nabiz egzersiz boy
## Kadın:85 Min. :16.92 Min. : 35.00 Sık :86 Min. :152.0
## Erkek:85 1st Qu.:17.67 1st Qu.: 66.25 Yok :14 1st Qu.:165.0
## Median :18.58 Median : 72.00 Bazen:70 Median :171.0
## Mean :20.46 Mean : 73.92 Mean :172.5
## 3rd Qu.:20.17 3rd Qu.: 80.00 3rd Qu.:180.0
## Max. :70.42 Max. :104.00 Max. :200.0
## sigara
## Fazla : 7
## Hiç :136
## Ara Sıra: 13
## Düzenli : 14
##
##
table(veri_son$cinsiyet)
##
## Kadın Erkek
## 85 85
prop.table(table(veri_son$cinsiyet))*100
##
## Kadın Erkek
## 50 50
table(veri_son$sigara)
##
## Fazla Hiç Ara Sıra Düzenli
## 7 136 13 14
prop.table(table(veri_son$sigara))*100
##
## Fazla Hiç Ara Sıra Düzenli
## 4.117647 80.000000 7.647059 8.235294
veri_son %>% count(sigara) %>% mutate (yuzde=round((n/sum(n))*100,2))
## sigara n yuzde
## 1 Fazla 7 4.12
## 2 Hiç 136 80.00
## 3 Ara Sıra 13 7.65
## 4 Düzenli 14 8.24
veri_son %>% count(egzersiz) %>% mutate(yuzde=round((n/sum(n))*100,2))
## egzersiz n yuzde
## 1 Sık 86 50.59
## 2 Yok 14 8.24
## 3 Bazen 70 41.18
veri_son %>% group_by(egzersiz) %>% summarise(ortalama_nabiz=round(mean(nabiz),2))
## # A tibble: 3 × 2
## egzersiz ortalama_nabiz
## <fct> <dbl>
## 1 Sık 71.4
## 2 Yok 75.9
## 3 Bazen 76.6
mean(veri_son$boy)
## [1] 172.5198
median(veri_son$boy)
## [1] 171
library(lsr)
modeOf(veri_son$boy)
## [1] 165