how can i cross all variables against each other and obtain chi square test values in r?

You can use comb function to find all combinations and run any number of variables against each other.

As a simple solution, if you have a data.table named dt, and the independent variable is result, then use the following code.


chi_dt <- dt %>%
  map(~chisq.test(.x, dt$result)) %>%
  tibble(names = names(.), data = .) %>%
  mutate(stats = map(data, broom::tidy)) %>%
  unnest(stats)  %>% select(-data) %>%
  arrange(p.value, desc(statistic))

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top