I would like to run a Dunn test with the purrr package. However, the tidy function to extract the parameter/results seemed to do not work with this test. Any one has sugesstion for me?
My example.
df <- data.frame(Type = c("n1", "n1", "n2", "n2", "n3", "n3", "n4", "n4", "n1", "n1", "n2", "n2", "n3", "n3", "n4", "n4"),
group = c("gr1", "gr1", "gr1", "gr1", "gr1", "gr1", "gr1", "gr1", "gr2", "gr2", "gr2", "gr2", "gr2", "gr2", "gr2", "gr2"),
value = runif(16, min = 1, max = 30))
tbl <- df %>%
mutate(Type = factor(Type, levels = c("n1", "n2", "n3", "n4"))) %>%
nest(data = -group) %>%
mutate(fit = map(data, ~dunnTest(value~Type, data= .x, method = "bh")),
tidied = map(fit, tidy))
Error: Problem with `mutate()` column `tidied`.
i `tidied = map(fit, tidy)`.
x No tidy method for objects of class dunnTest
Run `rlang::last_error()` to see where the error occurred.
The
dunnTest(assuming it is fromFSA) returns alistas output. We may need to extract the 'res' element-output
If we don't need the 'data' column either
selectout or usetransmute-output
The output is already a
tidyieddata.frameif we extract thelisti.e. check thestrof the outputThere is no need for the
purrrto be used here if we are usingnest_bywhich doesrowwiseattribute. In case, we are onlynesting then-output