Skip to content

Commit 4c60ac3

Browse files
authored
oneway.test: Error in paste0(out$interpretation, " (", out$statistics, ")"): object 'out' not found (#441)
* oneway.test: `Error in paste0(out$interpretation, " (", out$statistics, ")"): object 'out' not found` Fixes #394 * fix
1 parent d8feb3f commit 4c60ac3

File tree

2 files changed

+31
-44
lines changed

2 files changed

+31
-44
lines changed

R/report.htest.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ report_effectsize.htest <- function(x, ...) {
9090

9191
# TODO: Chi-squared test -------------
9292

93-
if (model_info$is_proptest || (model_info$is_xtab && !model_info$is_chi2test)) {
93+
if (model_info$is_proptest || (model_info$is_xtab && !model_info$is_chi2test) || model_info$is_onewaytest) {
9494
stop(insight::format_message(
9595
"This test is not yet supported. Please open an issue at {.url https://github.com/easystats/report/issues}."
9696
), call. = FALSE)

R/report_htest_chi2.R

+30-43
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,35 @@
99
# report_effectsize ---------------------
1010

1111
.report_effectsize_chi2 <- function(x, table, dot_args, rules = "funder2019") {
12-
if (chi2_type(x) %in% c("pearson", "probabilities")) {
13-
args <- c(list(x), dot_args)
14-
table <- do.call(effectsize::effectsize, args)
15-
table_footer <- attributes(table)$table_footer
16-
ci <- attributes(table)$ci
17-
estimate <- names(table)[1]
18-
rules <- ifelse(is.null(dot_args$rules), rules, dot_args$rules)
19-
20-
args <- c(list(table, rules = rules), dot_args)
21-
interpretation <- do.call(effectsize::interpret, args)$Interpretation
22-
rules <- .text_effectsize(attr(attr(interpretation, "rules"), "rule_name"))
23-
} else {
24-
stop(insight::format_message(
12+
if (!chi2_type(x) %in% c("pearson", "probabilities")) {
13+
insight::format_error(
2514
"This test is not yet supported. Please open an issue at {.url https://github.com/easystats/report/issues}."
26-
), call. = FALSE)
27-
}
28-
29-
if (estimate == "Cramers_v_adjusted") {
30-
main <- paste0("Adjusted Cramer's v = ", insight::format_value(table[[estimate]]))
31-
} else if (estimate == "Fei") {
32-
main <- paste0("Fei = ", insight::format_value(table[[estimate]]))
33-
} else if (estimate == "Tschuprows_t") {
34-
main <- paste0("Tschuprow's t = ", insight::format_value(table[[estimate]]))
35-
} else if (estimate == "Tschuprows_t_adjusted") {
36-
main <- paste0("Adjusted Tschuprow's t = ", insight::format_value(table[[estimate]]))
37-
} else if (estimate == "Pearsons_c") {
38-
main <- paste0("Pearson's c = ", insight::format_value(table[[estimate]]))
39-
} else if (estimate == "phi_adjusted") {
40-
main <- paste0("Adjusted Phi = ", insight::format_value(table[[estimate]]))
41-
} else if (estimate == "Cohens_h") {
42-
main <- paste0("Cohen's h = ", insight::format_value(table[[estimate]]))
43-
} else if (estimate == "Odds_ratio") {
44-
main <- paste0("Odds ratio = ", insight::format_value(table[[estimate]]))
45-
} else if (estimate == "Ris_kratio") {
46-
main <- paste0("Risk ratio = ", insight::format_value(table[[estimate]]))
47-
} else if (estimate == "cohens_h") {
48-
main <- paste0("Cohen's w = ", insight::format_value(table[[estimate]]))
49-
} else {
50-
main <- paste0(estimate, " = ", insight::format_value(table[[estimate]]))
15+
)
5116
}
17+
es_args <- c(list(x), dot_args)
18+
table <- do.call(effectsize::effectsize, es_args)
19+
table_footer <- attributes(table)$table_footer
20+
ci <- attributes(table)$ci
21+
estimate <- names(table)[1]
22+
rules <- ifelse(is.null(dot_args$rules), rules, dot_args$rules)
23+
24+
es_args <- c(list(table, rules = rules), dot_args)
25+
interpretation <- do.call(effectsize::interpret, es_args)$Interpretation
26+
rules <- .text_effectsize(attr(attr(interpretation, "rules"), "rule_name"))
27+
28+
main <- switch(estimate,
29+
Cramers_v_adjusted = paste0("Adjusted Cramer's v = ", insight::format_value(table[[estimate]])),
30+
Fei = paste0("Fei = ", insight::format_value(table[[estimate]])),
31+
Tschuprows_t = paste0("Tschuprow's t = ", insight::format_value(table[[estimate]])),
32+
Tschuprows_t_adjusted = paste0("Adjusted Tschuprow's t = ", insight::format_value(table[[estimate]])),
33+
Pearsons_c = paste0("Pearson's c = ", insight::format_value(table[[estimate]])),
34+
phi_adjusted = paste0("Adjusted Phi = ", insight::format_value(table[[estimate]])),
35+
Cohens_h = paste0("Cohen's h = ", insight::format_value(table[[estimate]])),
36+
Odds_ratio = paste0("Odds ratio = ", insight::format_value(table[[estimate]])),
37+
Ris_kratio = paste0("Risk ratio = ", insight::format_value(table[[estimate]])),
38+
cohens_h = paste0("Cohen's w = ", insight::format_value(table[[estimate]])),
39+
paste0(estimate, " = ", insight::format_value(table[[estimate]]))
40+
)
5241

5342
statistics <- paste0(
5443
main,
@@ -79,24 +68,22 @@
7968
vars_full <- paste0(names(attributes(x$observed)$dimnames), collapse = " and ")
8069
} else if (chi2_type(x) == "probabilities") {
8170
type <- " / goodness of fit of "
82-
dist <- ifelse(
71+
distr <- ifelse(
8372
grepl("non", attr(table, "table_footer"), fixed = TRUE), "a uniform distribution",
8473
paste0("a distribution of [", paste0(
8574
names(x$expected), ": n=", x$expected,
8675
collapse = ", "
8776
), "]")
8877
)
8978

90-
vars_full <- paste(x$data.name, "to", dist)
79+
vars_full <- paste(x$data.name, "to", distr)
9180
}
9281

93-
text <- paste0(
82+
paste0(
9483
trimws(x$method),
9584
type,
9685
paste0(" ", vars_full)
9786
)
98-
99-
text
10087
}
10188

10289
chi2_type <- function(x) {

0 commit comments

Comments
 (0)