I have data frame like
library(rstatix)
grp1 <- runif(10, min = 0, max = 100) # Exemple de données numériques
grp2 <- runif(10, min = 0, max = 100)
grp3 <- runif(10, min = 0, max = 100)
grp4 <- runif(10, min = 0, max = 100)
status <- sample(c("alive", "death", "sick"), 10, replace = TRUE) # Exemple de données caractère
my_data_frame <- data.frame(grp1, grp2, grp3, grp4, status)
and I want to do for each group.
wilcox_test(grp1~ status, p.adjust.method = "fdr")
I try
for (i in 4) {
var <- names(my_data_frame)
test <- my_data_frame %>% wilcox_test(var[i] ~ status, p.adjust.method = "fdr")}
but Column var[i] doesn't exist.
with other test like glm this syntax works
rstatixis designed to fit nicely into Tidyverse-based workflows and pipelines, so instead of a loop, you could first pivot your dataset to longer, group and pass grouped tibble towilcox_test():Created on 2024-02-09 with reprex v2.1.0