Created
February 3, 2023 21:11
-
-
Save jrosell/d586ecb9b1f3fff61a3ba5830c091e2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
datos <- structure(list(Genero = c(2, 1, 1, 2, 1, 1, 1, 2, 2, 2), | |
`1. En casa` = c(1, 3, 1, 3, 4, 2, 4, 5, 5, 5), | |
`2. Con la tele` = c(4, 2, 1, 2, 3, 3, 2, 1, 1, 1)), | |
row.names = c(NA, -10L), | |
class = c("tbl_df", "tbl", "data.frame")) | |
# Opción con stats::wilcox.test | |
datos |> | |
dplyr::select(-Genero) |> | |
purrr::map_df(function(x){ | |
stats::wilcox.test(x ~ datos$Genero) |> | |
broom::tidy() | |
}) | |
# Opción con rstatix::wilcox_test | |
library(tidyverse) | |
paste0("`", names(datos[-1]), "` ~ Genero") %>% | |
map_df(function(x) { | |
rstatix::wilcox_test(formula = as.formula(x), data = datos) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment