head(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
n <- nrow(iris) # toplam satır sayısı
mu <- round(mean(iris$Petal.Length),2) # yaprak uzunluğu ortalaması
sd <- round(sd(iris$Petal.Length),2) # yaprak uzunluğu SD'si
# simule_deger <- rnorm(n, mu, sd)
iris veri seti 150 satıra sahiptir. Taç yaprak uzunluğu ortaması 3.76 ,standart sapması ise 1.77 dir.
# analiz
setosa_petal <- filter(iris, Species == "setosa") %>% pull(Petal.Length)
virginica_petal <- filter(iris, Species == "virginica") %>% pull(Petal.Length)
petal_test <- t.test(setosa_petal, virginica_petal)
# rapor edilecek degerleri yorumlama
t <- petal_test$statistic %>% round(2)
df <- petal_test$parameter %>% round(1)
p <- petal_test$p.value %>% round(3)
# handle p-values < .001
p_symbol <- ifelse(p < .001, "<", "=")
if (p < .001) p <- .001
# sonucları birleştirme
petal_result <- glue::glue("t = {t}, df = {df}, p {p_symbol} {p}")
petal_result
## t = -49.99, df = 58.6, p < 0.001