I have this data:
df <- structure(list(`Orientación dicotómica` = c("Neurogastro", "Neurogastro",
"Neurogastro", "Neurogastro", "No neurogastro", "No neurogastro",
"No neurogastro", "No neurogastro", "No neurogastro"), `Fisiopatología más frecuente variante constipación` = c("Más de una variante",
"Obstrucción del tracto de salida", "Tránsito lento / Inercia",
"Transito normal", "Más de una variante", "Obstrucción del tracto de salida",
"Tránsito lento / Inercia", "Transito normal", "Uso de fármacos"
), n = c(22L, 8L, 12L, 11L, 108L, 12L, 101L, 25L, 1L), Proporcion = c(41.5,
15.1, 22.6, 20.8, 43, 4.8, 40.2, 10, 0.4), ds = c(11.5, 11.5,
11.5, 11.5, 19.6, 19.6, 19.6, 19.6, 19.6), IC25 = c(32, 5.6,
13.1, 11.3, 29.8, -8.4, 27, -3.2, -12.8), IC75 = c(51, 24.6,
32.1, 30.3, 56.2, 18, 53.4, 23.2, 13.6)), row.names = c(NA, -9L
), class = c("tbl_df", "tbl", "data.frame"), na.action = structure(c(`10` = 10L), class = "omit"))
Which looks like this:
And I'm trying to run a chisq test with grouped data to analyse if there's a statistically significant difference between "neurogastro" and "no neurogastro" regarding the "fisiopatología más frecuente".
As published in Chi -Square test with grouped data in dplyr
I have tried
test <- df %>%
group_by(`Fisiopatología más frecuente variante constipación`) %>%
summarise(pval = chisq.test(Proporcion,`Orientación dicotómica`)$p.value)
But I get an error which I guess is because there is no "Uso de fármacos" for neurogastro. Is my approach ok? How can I run the test for the rest of the groups except the one missing?
Thanks!