rstatix
rstatix copied to clipboard
chisq_test() does not appear to accept piped data
chisq_test()
seems to only expect a table. Since the goal of the package is to work with pipes, it seems like this is counterintuitive:
require(tidyverse)
#> Loading required package: tidyverse
diamonds %>% rstatix::chisq_test(cut, clarity)
#> Error in as.list.environment(environment()): object 'clarity' not found
diamonds %>% table(cut, clarity) %>% rstatix::chisq_test(cut, clarity)
#> Error in table(., cut, clarity): object 'clarity' not found
table(diamonds$cut, diamonds$clarity) %>% rstatix::chisq_test(cut, clarity)
#> Error in as.list.environment(environment()): object 'clarity' not found
table(diamonds$cut, diamonds$clarity) %>% rstatix::chisq_test()
#> # A tibble: 1 x 6
#> n statistic p df method p.signif
#> * <int> <dbl> <dbl> <int> <chr> <chr>
#> 1 53940 4391. 0 28 Chi-square test ****
Created on 2020-05-05 by the reprex package (v0.3.0)
Ah - came to ask the exact some question. @kassambara are we missing something fundamental in chisq_test()
?
Yup, me too :-) It essentially works like a standard chisq.test?
Looks like it's exactly the same as chisq.test()
l just wanted to add to others that it would be great to see this working as expected!
I would also like this feature. I can only seem to make it work inside summarise()
+ unnest()
library(tidyverse)
library(rstatix)
diamonds |>
summarise(pval = chisq_test(cut, clarity)) |>
unnest(pval)
# vs
diamonds |>
kruskal_test(price ~ clarity)