I am using the reportpackage. I had no problems when doing a t-test, only with Wilcoxon I have problem.
This code gives a report independently of the variable Session. How can I obtain two reports, one for each Session, using a Wilcoxon paired test?
I tried group_by without success and I don't know what to do after split(df, df$Session).
library(tidyverse)
library(report)
df <- tibble(Session = c(rep("1", 10), rep("2", 10)),
scores = sample(20:70, 20),
group = c(rep("before", 5), rep("after",5),
rep("before", 5), rep("after",5)))
wilcox.test(df$scores ~ df$group, paired = TRUE) |> report()
#> Effect sizes were labelled following Funder's (2019) recommendations.
#>
#> The Wilcoxon signed rank exact test testing the difference in ranks between
#> df$scores and df$group suggests that the effect is negative, statistically not
#> significant, and small (W = 24.00, p = 0.770; r (rank biserial) = -0.13, 95% CI
#> [-0.68, 0.52])
library(report)
set.seed(42)
d <- data.frame(Session = c(rep("1", 10), rep("2", 10)),
scores = sample(20:70, 20),
group = c(rep("before", 5), rep("after",5),
rep("before", 5), rep("after",5)))
s1 <- d[which(d$Session == "1"),]
wilcox.test(s1$scores ~s1$group, paired = TRUE) |> report()
#> Effect sizes were labelled following Funder's (2019) recommendations.
#>
#> The Wilcoxon signed rank exact test testing the difference in ranks between
#> s1$scores and s1$group suggests that the effect is positive, statistically not
#> significant, and small (W = 9.00, p = 0.812; r (rank biserial) = 0.20, 95% CI
#> [-0.64, 0.82])
s2 <- d[which(d$Session == "2"),]
wilcox.test(s2$scores ~s2$group, paired = TRUE) |> report()
#> Effect sizes were labelled following Funder's (2019) recommendations.
#>
#> The Wilcoxon signed rank exact test testing the difference in ranks between
#> s2$scores and s2$group suggests that the effect is negative, statistically not
#> significant, and very small (W = 7.00, p > .999; r (rank biserial) = -0.07, 95%
#> CI [-0.78, 0.72])
Probably. For some reason, I ran into a problem trying to write a function to do that, but I didn’t give it much effort. Why don’t you have a go and report back.