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(ggplot2)
library(palmerpenguins)
##
## Attaching package: 'palmerpenguins'
## The following objects are masked from 'package:datasets':
##
## penguins, penguins_raw
data("penguins")
names(penguins)
## [1] "species" "island" "bill_length_mm"
## [4] "bill_depth_mm" "flipper_length_mm" "body_mass_g"
## [7] "sex" "year"
glimpse(penguins)
## Rows: 344
## Columns: 8
## $ species <fct> Adelie, Adelie, Adelie, Adelie, Adelie, Adelie, Adel…
## $ island <fct> Torgersen, Torgersen, Torgersen, Torgersen, Torgerse…
## $ bill_length_mm <dbl> 39.1, 39.5, 40.3, NA, 36.7, 39.3, 38.9, 39.2, 34.1, …
## $ bill_depth_mm <dbl> 18.7, 17.4, 18.0, NA, 19.3, 20.6, 17.8, 19.6, 18.1, …
## $ flipper_length_mm <int> 181, 186, 195, NA, 193, 190, 181, 195, 193, 190, 186…
## $ body_mass_g <int> 3750, 3800, 3250, NA, 3450, 3650, 3625, 4675, 3475, …
## $ sex <fct> male, female, female, NA, female, male, female, male…
## $ year <int> 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007…
penguins_tr<-penguins %>%
rename(
tür=species,
ada=island,
gaga_uzunluk=bill_length_mm,
gaga_derinlik=bill_depth_mm,
yüzgec_uzunluk=flipper_length_mm,
kilo=body_mass_g,
cinsiyet=sex,
yil=year
)
names(penguins_tr)
## [1] "tür" "ada" "gaga_uzunluk" "gaga_derinlik"
## [5] "yüzgec_uzunluk" "kilo" "cinsiyet" "yil"
penguins_tr<-penguins_tr|>
select(kilo,yüzgec_uzunluk)|>
na.omit()
ggplot(penguins_tr,aes(x=yüzgec_uzunluk,y=kilo))+
geom_point()+
labs(x="Yüzgeç Uzunluğu (mm)",
y="Vücut Ağırlığı(gram)",
title = "Yüzgeç Uzunluğu ile Vücut Ağırlığı İlişkisi")

peng_mod<-lm(kilo~yüzgec_uzunluk,data = penguins_tr)
summary(peng_mod)
##
## Call:
## lm(formula = kilo ~ yüzgec_uzunluk, data = penguins_tr)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1058.80 -259.27 -26.88 247.33 1288.69
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -5780.831 305.815 -18.90 <2e-16 ***
## yüzgec_uzunluk 49.686 1.518 32.72 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 394.3 on 340 degrees of freedom
## Multiple R-squared: 0.759, Adjusted R-squared: 0.7583
## F-statistic: 1071 on 1 and 340 DF, p-value: < 2.2e-16
coef(peng_mod)
## (Intercept) yüzgec_uzunluk
## -5780.83136 49.68557
ggplot(penguins_tr,aes(x=yüzgec_uzunluk,y=kilo))+
geom_point()+
geom_smooth(method = "lm",se=FALSE,color="red")+
labs(x="Yüzgeç Uzunluğu(mm)",
y="Vücut Ağırlığı(gram)",
title = "Basit Doğrusal Regresyon Çizgisi"
)+
theme_get()
## `geom_smooth()` using formula = 'y ~ x'

library(MASS)
##
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
##
## select
library(dplyr)
library(ggplot2)
data("survey")
names(survey)
## [1] "Sex" "Wr.Hnd" "NW.Hnd" "W.Hnd" "Fold" "Pulse" "Clap" "Exer"
## [9] "Smoke" "Height" "M.I" "Age"
ggplot(
data = survey,
aes(x=Age,y=Pulse)
)+
geom_point()
## Warning: Removed 45 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggplot(
data=survey,
aes(x=Age,y=Pulse)
)+
geom_point()+
labs(
x="YaÅŸ",
y="Nabız",
title="Yaş ile Nabız Arasındaki İlişki"
)
## Warning: Removed 45 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggplot(
data=survey,
aes(x=Age,y=Pulse)
)+
geom_point()+
labs(
x="YaÅŸ",
y="Nabız",
title="Yaş ile Nabız Arasındaki İlişki"
)+
geom_smooth(
se=FALSE,
color="orange"
)
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 45 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 45 rows containing missing values or values outside the scale range
## (`geom_point()`).

cor(
survey$Wr.Hnd,
survey$NW.Hnd,
use = "pairwise.complete.obs"
)
## [1] 0.9483103
cor(
survey$Age,
survey$Pulse,
use ="pairwise.complete.obs"
)
## [1] -0.1180616
ggplot(
survey,
aes(x=Wr.Hnd,y=NW.Hnd)
)+
geom_point()+
geom_smooth(
se=FALSE,
color="red"
)+
labs(
x="SaÄŸ El GeniÅŸliÄŸi(cm)",
y="Yazı Yazılmayan El Genişliği(cm)",
title = "İki El Genişliği Arasındaki İlişki"
)
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 1 row containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).
