Closed tklebel closed 8 years ago
should have sensible default: fisher.test()
and vcd::assocstats$cramer
probably.
Statistics should be supplied in a simple way (not: fisher = T
). Is there a simpler possibility?
Possibly: add_stats(~fisher, ~chisq, ~cramer)
Alternatively, with the need to quote:
ad_stats <- function(...) {
test <- match.arg(..., c("cramer", "chisq", "fisher"), several.ok = T)
switch(test,
cramer = assocstats(x)$cramer,
chisq = chisq.test(x),
fisher = fisher.test(x))
}
although switch
wouldn't work here: it just computes the first match. would need something else.
Could work like this:
ad_stats <- function(...) {
test <- match.arg(..., c("cramer", "chisq", "fisher"), several.ok = T)
if ("fisher" %in% test) {
fisher <– fisher.test(x)
}
...
}
add_stats
should take arguments as a vector and output a box with stats, taken fromvcd::assocstats
(Chi-square, Cramers-V, ...)