library(MASS)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following object is masked from 'package:MASS':
##
## select
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.5.2
data("Boston")
names(Boston)
## [1] "crim" "zn" "indus" "chas" "nox" "rm" "age"
## [8] "dis" "rad" "tax" "ptratio" "black" "lstat" "medv"
boston_tr <-Boston %>%
dplyr::select(medv ,rm,lstat,chas,tax)
boston_tr<-boston_tr %>%
rename(konut_degeri= medv,
oda_sayisi= rm,
dusuk_sosyoek= lstat,
nehir_kenari= chas,
emlak_vergisi= tax)
summary(boston_tr)
## konut_degeri oda_sayisi dusuk_sosyoek nehir_kenari
## Min. : 5.00 Min. :3.561 Min. : 1.73 Min. :0.00000
## 1st Qu.:17.02 1st Qu.:5.886 1st Qu.: 6.95 1st Qu.:0.00000
## Median :21.20 Median :6.208 Median :11.36 Median :0.00000
## Mean :22.53 Mean :6.285 Mean :12.65 Mean :0.06917
## 3rd Qu.:25.00 3rd Qu.:6.623 3rd Qu.:16.95 3rd Qu.:0.00000
## Max. :50.00 Max. :8.780 Max. :37.97 Max. :1.00000
## emlak_vergisi
## Min. :187.0
## 1st Qu.:279.0
## Median :330.0
## Mean :408.2
## 3rd Qu.:666.0
## Max. :711.0
median(boston_tr$konut_degeri)
## [1] 21.2
#konut değerinin medyan değeri 21.2 dir
mean(boston_tr$konut_degeri)
## [1] 22.53281
#ortalama değeri 22.53281 dir.
table(boston_tr$nehir_kenari)
##
## 0 1
## 471 35
prop.table(table(boston_tr$nehir_kenari))*100
##
## 0 1
## 93.083004 6.916996
boston_tr %>%
count(nehir_kenari) %>%
mutate(yuzde=round(n/sum(n))*100,2)
## nehir_kenari n yuzde 2
## 1 0 471 100 2
## 2 1 35 0 2
boston_tr<-boston_tr|>
select(oda_sayisi,konut_degeri)|>
na.omit()
ggplot(boston_tr,aes(x=oda_sayisi,y=konut_degeri))+
labs(x="oda saysı(rm)",y="konut_degeri(medv)",
title="oda sayısı ve konut degeri ilişkisi")
ggplot(boston_tr,aes(x=oda_sayisi,y=konut_degeri))+
geom_point()+
geom_smooth(method = "Im",se=FALSE,color="red")+
labs(x="oda_sayısı(rm)",y="konut_degeri(medv)",
title ="oda sayısı ve konut değeri arasındaki ilişki")
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Failed to fit group -1.
## Caused by error in `compute_group()`:
## ! 'weight' nesnesi bulunamadı
coef(boston_tr)
## NULL
eğim (β₁)
kesişim (β₀)
R-kare (R²)
ggplot(boston_tr,aes(x=oda_sayisi,y=konut_degeri))+
geom_point()+
geom_smooth(method = "Im",se=FALSE,color="red")+
labs(x="oda_sayısı(rm)",y="konut_degeri(medv)",
title ="oda sayısı ve konut değeri arasındaki ilişki")
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Failed to fit group -1.
## Caused by error in `compute_group()`:
## ! 'weight' nesnesi bulunamadı
## 'geom_smooth()'using formula='y~x'
geom_jitter fonksiyonunun kullanım amacı
nedir?#regresyon için kullanılır,