Veri Üretim

Burada iki koşullu bir çalışmadan elde edilen verileri simüle edeceğiz. A koşulundaki ortalama 0 ve B koşulundaki ortalama 1’dir.

n <- 100

data <- data.frame(
  id = 1:n,
  condition = c("A", "B") |> rep(each = n/2),
  dv = c(rnorm(n/2, 0), rnorm(n/2, 1))
)

Grafik

library(datasets)
data(iris)
n <- nrow(iris) # toplam satır sayısı
mu <- mean(iris$Petal.Length)  # taç yaprak uzunluğu ortalaması
sd <- sd(iris$Petal.Length) # taç yaprak uzunluğu standart sapması

set.seed(41)
simule_deger <- rnorm(n, mu, sd)

tac yaprak uzunlugu ortalaması 3.76 dir.

# analiz
library(dplyr)
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

virginica çiçeklerinin yaprakları (\(\overline{X_v}\)=5.55) setosa çiçeklerinin yapraklarından (\(\overline{X_s}\)=1.46) uzundur(t = -49.99, df = 58.6, p < 0.001).

###tablo oluşturmaca

 library(knitr)
## Warning: package 'knitr' was built under R version 4.3.3
 ozet_tablo <- iris %>%
  group_by(Species) %>%
  summarise(
    n = n(),
    ortalama = mean(Petal.Length),
    sd = sd(Petal.Length)
  )
ozet_tablo %>% kable(col.names = c("Turler","f","Ort","sd"),digits = 2)
Turler f Ort sd
setosa 50 1.46 0.17
versicolor 50 4.26 0.47
virginica 50 5.55 0.55
library(kableExtra)

kable(ozet_tablo,
      digits = 2,
      col.names = c("Cicek Turu", "Frekans", "Ortalama", "Sd"),
      caption = "Petal Uzulukları için Ozet Tablo") |>
  kable_classic() |>
  kable_styling(full_width = FALSE, font_size = 20) |>
  add_header_above(c(" " = 2, "Degerler" = 2)) |>
  kableExtra::row_spec(2, bold = TRUE, background = "lightgrey")
Petal Uzulukları için Ozet Tablo
Degerler
Cicek Turu Frekans Ortalama Sd
setosa 50 1.46 0.17
versicolor 50 4.26 0.47
virginica 50 5.55 0.55
col1 col2 col3
aa bb aa
dat <- subset(iris, Species != "versicolor")
dat$Species <- factor(dat$Species)

ggplot(dat, aes(Species, Petal.Length)) +
  geom_boxplot(width = 0.25,
               show.legend = FALSE)  +
  labs(x = "", y = "Petal Uzunluğu") +
  theme(text = element_text(size = 20, family = "Times"))
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## not found in Windows font database
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database

neden R
neden R

###isim şeklinde bağlantı ekle. başa ünlem koyarsan resim olarak ekler (link veya images/dosya adı şeklinde)