Problem with `mutate()` input `data`.

I'm getting an error and I'm not sure what is wrong with my data. When looking over the raw file, I can't tell what needs to be fixed. Help?

Error: Problem with mutate() input data.
x missing value where TRUE/FALSE needed
:information_source: Input data is map(.data$data, .f, ...).

Can you provide a reproducible example? It will help if you show us some code and an example of your data. FAQ: How to do a minimal reproducible example ( reprex ) for beginners

library(rstatix)

these data are titled spleen

#statistical test run

stat.test <- spleen %>% group_by(group,detail)%>%

  • wilcox_test(value ~ sex, paired = FALSE)
    

#error
Error: Problem with mutate() input data.
x missing value where TRUE/FALSE needed
:information_source: Input data is map(.data$data, .f, ...).

Please provide your data in code rather than as a screenshot. We can test it if it is in code (see the article).

Can you post the output of dput(spleen) or dput(head(spleen)) if there is a lot of data?

dput(spleen)
structure(list(aid = c("A1", "A2", "A3", "A4", "B1", "B2", "B3",
"B4", "C1", "C2", "C3", "C4", "D1", "D2", "D3", "D4", "E1", "E2",
"E3", "E4", "F1", "F2", "F3", "F4"), tissue = c("sp", "sp", "sp",
"sp", "sp", "sp", "sp", "sp", "sp", "sp", "sp", "sp", "sp", "sp",
"sp", "sp", "sp", "sp", "sp", "sp", "sp", "sp", "sp", "sp"),
group = c("A", "A", "A", "A", "B", "B", "B", "B", "C", "C",
"C", "C", "A", "A", "A", "A", "B", "B", "B", "B", "C", "C",
"C", "C"), sex = c("m", "m", "m", "m", "m", "m", "m", "m",
"m", "m", "m", "m", "f", "f", "f", "f", "f", "f", "f", "f",
"f", "f", "f", "f"), detail = c("mCD4", "mCD4", "mCD4", "mCD4",
"mCD4", "mCD4", "mCD4", "mCD4", "mCD4", "mCD4", "mCD4", "mCD4",
"mCD4", "mCD4", "mCD4", "mCD4", "mCD4", "mCD4", "mCD4", "mCD4",
"mCD4", "mCD4", "mCD4", "mCD4"), value = c(0, 0, 0, 0, 0,
0, 0, 0.46, 0, 0, 0, 0, 0, 0, 0, 0.31, 0, 0, 0, 0.47, 0,
0, 0, 0)), class = c("spec_tbl_df", "tbl_df", "tbl", "data.frame"
), row.names = c(NA, -24L), spec = structure(list(cols = list(
aid = structure(list(), class = c("collector_character",
"collector")), tissue = structure(list(), class = c("collector_character",
"collector")), group = structure(list(), class = c("collector_character",
"collector")), sex = structure(list(), class = c("collector_character",
"collector")), detail = structure(list(), class = c("collector_character",
"collector")), value = structure(list(), class = c("collector_double",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), skip = 1), class = "col_spec"))

In the example, the grouping variable seems to be numeric. It is strange that you can't do it with a factor variable.

Perhaps raise an issue:

The wilcox.test function has this form when used with a formula

wilcox.test(formula, data, subset, na.action, ...)

You cannot use the %>% operator to pass in the data set because data is the second argument of wilcox.test, not the first. Also, I doubt wilcos.test knows how to handle the result of group_by(). You should use the subset argument.

It is a different wilcox_test() from the package rstatix.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.