Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oneway.test: Error in paste0(out$interpretation, " (", out$statistics, ")"): object 'out' not found #441

Merged
merged 4 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/report.htest.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#' @export
report.htest <- function(x, ...) {
model_info <- insight::model_info(x, verbose = FALSE)
table <- report_table(x, model_info = model_info, ...)

Check warning on line 29 in R/report.htest.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.htest.R,line=29,col=3,[object_overwrite_linter] 'table' is an exported object from package 'base'. Avoid re-using such symbols.
text <- report_text(x, table = table, model_info = model_info, ...)

Check warning on line 30 in R/report.htest.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.htest.R,line=30,col=3,[object_overwrite_linter] 'text' is an exported object from package 'graphics'. Avoid re-using such symbols.

as.report(text, table = table, ...)
}
Expand Down Expand Up @@ -90,7 +90,7 @@

# TODO: Chi-squared test -------------

if (model_info$is_proptest || (model_info$is_xtab && !model_info$is_chi2test)) {
if (model_info$is_proptest || (model_info$is_xtab && !model_info$is_chi2test) || model_info$is_onewaytest) {
stop(insight::format_message(
"This test is not yet supported. Please open an issue at {.url https://github.com/easystats/report/issues}."
), call. = FALSE)
Expand Down Expand Up @@ -127,9 +127,9 @@
# remove arg, so dots can be passed to effectsize
dot_args[["model_info"]] <- NULL

args <- c(list(x), dot_args)

Check warning on line 130 in R/report.htest.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.htest.R,line=130,col=3,[object_overwrite_linter] 'args' is an exported object from package 'base'. Avoid re-using such symbols.
table_full <- do.call(parameters::model_parameters, args)
args <- c(list(x, model_info = model_info), dot_args)

Check warning on line 132 in R/report.htest.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.htest.R,line=132,col=3,[object_overwrite_linter] 'args' is an exported object from package 'base'. Avoid re-using such symbols.
effsize <- do.call(report_effectsize, args)

if (model_info$is_ttest) {
Expand Down Expand Up @@ -169,7 +169,7 @@
}

effsize <- attributes(table)$effsize
text <- NULL

Check warning on line 172 in R/report.htest.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.htest.R,line=172,col=3,[object_overwrite_linter] 'text' is an exported object from package 'graphics'. Avoid re-using such symbols.

# Estimate
candidates <- c(
Expand All @@ -178,12 +178,12 @@
)
estimate <- candidates[candidates %in% names(table)][1]
if (!is.null(estimate) && !is.na(estimate)) {
text <- paste0(tolower(estimate), " = ", insight::format_value(table[[estimate]]))

Check warning on line 181 in R/report.htest.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.htest.R,line=181,col=5,[object_overwrite_linter] 'text' is an exported object from package 'graphics'. Avoid re-using such symbols.
}

# CI
if (!is.null(attributes(x$conf.int)$conf.level)) {
text <- paste0(

Check warning on line 186 in R/report.htest.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.htest.R,line=186,col=5,[object_overwrite_linter] 'text' is an exported object from package 'graphics'. Avoid re-using such symbols.
text,
", ",
insight::format_ci(
Expand All @@ -196,7 +196,7 @@

# Statistic
if ("t" %in% names(table)) {
text <- paste0(

Check warning on line 199 in R/report.htest.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.htest.R,line=199,col=5,[object_overwrite_linter] 'text' is an exported object from package 'graphics'. Avoid re-using such symbols.
text,
", t(",
insight::format_value(table$df, protect_integers = TRUE),
Expand All @@ -204,7 +204,7 @@
insight::format_value(table$t)
)
} else if ("S" %in% names(table)) {
text <- paste0(text, ", S = ", insight::format_value(table$S))

Check warning on line 207 in R/report.htest.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.htest.R,line=207,col=5,[object_overwrite_linter] 'text' is an exported object from package 'graphics'. Avoid re-using such symbols.
} else if ("z" %in% names(table)) {
text <- paste0(text, ", z = ", insight::format_value(table$z))
} else if ("W" %in% names(table)) {
Expand Down
73 changes: 30 additions & 43 deletions R/report_htest_chi2.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,35 @@
# report_effectsize ---------------------

.report_effectsize_chi2 <- function(x, table, dot_args, rules = "funder2019") {
if (chi2_type(x) %in% c("pearson", "probabilities")) {
args <- c(list(x), dot_args)
table <- do.call(effectsize::effectsize, args)
table_footer <- attributes(table)$table_footer
ci <- attributes(table)$ci
estimate <- names(table)[1]
rules <- ifelse(is.null(dot_args$rules), rules, dot_args$rules)

args <- c(list(table, rules = rules), dot_args)
interpretation <- do.call(effectsize::interpret, args)$Interpretation
rules <- .text_effectsize(attr(attr(interpretation, "rules"), "rule_name"))
} else {
stop(insight::format_message(
if (!chi2_type(x) %in% c("pearson", "probabilities")) {
insight::format_error(
"This test is not yet supported. Please open an issue at {.url https://github.com/easystats/report/issues}."
), call. = FALSE)
}

if (estimate == "Cramers_v_adjusted") {
main <- paste0("Adjusted Cramer's v = ", insight::format_value(table[[estimate]]))
} else if (estimate == "Fei") {
main <- paste0("Fei = ", insight::format_value(table[[estimate]]))
} else if (estimate == "Tschuprows_t") {
main <- paste0("Tschuprow's t = ", insight::format_value(table[[estimate]]))
} else if (estimate == "Tschuprows_t_adjusted") {
main <- paste0("Adjusted Tschuprow's t = ", insight::format_value(table[[estimate]]))
} else if (estimate == "Pearsons_c") {
main <- paste0("Pearson's c = ", insight::format_value(table[[estimate]]))
} else if (estimate == "phi_adjusted") {
main <- paste0("Adjusted Phi = ", insight::format_value(table[[estimate]]))
} else if (estimate == "Cohens_h") {
main <- paste0("Cohen's h = ", insight::format_value(table[[estimate]]))
} else if (estimate == "Odds_ratio") {
main <- paste0("Odds ratio = ", insight::format_value(table[[estimate]]))
} else if (estimate == "Ris_kratio") {
main <- paste0("Risk ratio = ", insight::format_value(table[[estimate]]))
} else if (estimate == "cohens_h") {
main <- paste0("Cohen's w = ", insight::format_value(table[[estimate]]))
} else {
main <- paste0(estimate, " = ", insight::format_value(table[[estimate]]))
)
}
es_args <- c(list(x), dot_args)
table <- do.call(effectsize::effectsize, es_args)
table_footer <- attributes(table)$table_footer
ci <- attributes(table)$ci
estimate <- names(table)[1]
rules <- ifelse(is.null(dot_args$rules), rules, dot_args$rules)

es_args <- c(list(table, rules = rules), dot_args)
interpretation <- do.call(effectsize::interpret, es_args)$Interpretation
rules <- .text_effectsize(attr(attr(interpretation, "rules"), "rule_name"))

main <- switch(estimate,
Cramers_v_adjusted = paste0("Adjusted Cramer's v = ", insight::format_value(table[[estimate]])),
Fei = paste0("Fei = ", insight::format_value(table[[estimate]])),
Tschuprows_t = paste0("Tschuprow's t = ", insight::format_value(table[[estimate]])),
Tschuprows_t_adjusted = paste0("Adjusted Tschuprow's t = ", insight::format_value(table[[estimate]])),
Pearsons_c = paste0("Pearson's c = ", insight::format_value(table[[estimate]])),
phi_adjusted = paste0("Adjusted Phi = ", insight::format_value(table[[estimate]])),
Cohens_h = paste0("Cohen's h = ", insight::format_value(table[[estimate]])),
Odds_ratio = paste0("Odds ratio = ", insight::format_value(table[[estimate]])),
Ris_kratio = paste0("Risk ratio = ", insight::format_value(table[[estimate]])),
cohens_h = paste0("Cohen's w = ", insight::format_value(table[[estimate]])),
paste0(estimate, " = ", insight::format_value(table[[estimate]]))
)

statistics <- paste0(
main,
Expand Down Expand Up @@ -76,27 +65,25 @@
.report_model_chi2 <- function(x, table) {
if (chi2_type(x) == "pearson") {
type <- " of independence between"
vars_full <- paste0(names(attributes(x$observed)$dimnames), collapse = " and ")

Check warning on line 68 in R/report_htest_chi2.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report_htest_chi2.R,line=68,col=18,[paste_linter] Use paste(), not paste0(), to collapse a character vector when sep= is not used.
} else if (chi2_type(x) == "probabilities") {
type <- " / goodness of fit of "
dist <- ifelse(
distr <- ifelse(
grepl("non", attr(table, "table_footer"), fixed = TRUE), "a uniform distribution",
paste0("a distribution of [", paste0(
names(x$expected), ": n=", x$expected,
collapse = ", "
), "]")
)

vars_full <- paste(x$data.name, "to", dist)
vars_full <- paste(x$data.name, "to", distr)
}

text <- paste0(
paste0(
trimws(x$method),
type,
paste0(" ", vars_full)
)

text
}

chi2_type <- function(x) {
Expand Down
Loading