This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
You can also embed plots, for example:
# Nalaganje potrebnih paketov
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.2.3
##
## 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(tidyr)
## Warning: package 'tidyr' was built under R version 4.2.3
library(broom)
library(purrr)
## Warning: package 'purrr' was built under R version 4.2.3
# Preberite podatke
podatki <- read.table("C:/Users/Benjamin/Downloads/podatki.csv", header=TRUE, sep=";", dec=",")
colnames(podatki) <- c("vzorec", "vrednost")
# Izpis prvih nekaj vrstic in strukture podatkov
print(head(podatki))
## vzorec vrednost
## 1 CON 0.5834238
## 2 CON 0.3476931
## 3 CON 0.5821974
## 4 CON 0.3792870
## 5 CON 0.4416285
## 6 CON 0.2896861
print(str(podatki))
## 'data.frame': 180 obs. of 2 variables:
## $ vzorec : chr "CON" "CON" "CON" "CON" ...
## $ vrednost: num 0.583 0.348 0.582 0.379 0.442 ...
## NULL
shapiro_results_podatki <- podatki %>%
group_by(vzorec) %>%
summarise(
shapiro_test = list(shapiro.test(vrednost)),
.groups = 'drop'
) %>%
mutate(
shapiro_test_tidy = map(shapiro_test, tidy),
p.value = map_dbl(shapiro_test_tidy, "p.value")
)
wilcox_result_podatki <- wilcox.test(vrednost ~ vzorec, data = podatki, paired = FALSE)
print(wilcox_result_podatki)
##
## Wilcoxon rank sum test with continuity correction
##
## data: vrednost by vzorec
## W = 1187, p-value = 4.538e-05
## alternative hypothesis: true location shift is not equal to 0
# Izračun velikosti učinka za podatki
# Izračunamo velikost učinka ročno
# Velikost učinka za Wilcoxonov test je približno enaka U-statistiki / (n1 * n2)
# Kjer sta n1 in n2 velikosti skupin
n1_podatki <- sum(podatki$vzorec == unique(podatki$vzorec)[1])
n2_podatki <- sum(podatki$vzorec == unique(podatki$vzorec)[2])
U_podatki <- wilcox_result_podatki$statistic
effect_size_podatki <- U_podatki / (n1_podatki * n2_podatki)
print(effect_size_podatki)
## W
## 0.2637778
# Preberite dodatne podatke
podatki2 <- read.table("C:/Users/Benjamin/Downloads/podatki2.csv", header=TRUE, sep=";", dec=",")
# Preverjanje Shapiro-Wilk testa
shapiro_results <- podatki2 %>%
group_by(vzorec) %>%
summarise(
shapiro_test = list(shapiro.test(vrednost)),
.groups = 'drop'
) %>%
mutate(
shapiro_test_tidy = map(shapiro_test, tidy),
p.value = map_dbl(shapiro_test_tidy, "p.value")
)
print(shapiro_results)
## # A tibble: 2 × 4
## vzorec shapiro_test shapiro_test_tidy p.value
## <chr> <list> <list> <dbl>
## 1 LUM A <htest> <tibble [1 × 3]> 0.452
## 2 TNRD <htest> <tibble [1 × 3]> 0.677
# Izvedba Wilcoxon testa
wilcox_result <- wilcox.test(vrednost ~ vzorec, data = podatki2, paired = FALSE)
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
print(wilcox_result)
##
## Wilcoxon rank sum test with continuity correction
##
## data: vrednost by vzorec
## W = 183, p-value = 0.3784
## alternative hypothesis: true location shift is not equal to 0
# Izračun velikosti učinka
# Izračunamo velikost učinka ročno
# Velikost učinka za Wilcoxonov test je približno enaka U-statistiki / (n1 * n2)
# Kjer sta n1 in n2 velikosti skupin
n1 <- sum(podatki2$vzorec == unique(podatki2$vzorec)[1])
n2 <- sum(podatki2$vzorec == unique(podatki2$vzorec)[2])
U <- wilcox_result$statistic
effect_size <- U / (n1 * n2)
print(effect_size)
## W
## 0.5980392
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.