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

model_parameters: Add variables names for chisq.test objects #896

Open
rempsyc opened this issue Aug 27, 2023 · 0 comments
Open

model_parameters: Add variables names for chisq.test objects #896

rempsyc opened this issue Aug 27, 2023 · 0 comments
Labels
enhancement 💥 Implemented features can be improved or revised

Comments

@rempsyc
Copy link
Sponsor Member

rempsyc commented Aug 27, 2023

Working on easystats/report#309 and experiencing the continuous joy of htest objects.

For example, model_parameters on a cor.test object will provide the names of the variables:

x <- cor.test(mtcars$mpg, mtcars$drat)
parameters::model_parameters(x)
#> Pearson's product-moment correlation
#> 
#> Parameter1 |  Parameter2 |    r |       95% CI | t(30) |      p
#> ---------------------------------------------------------------
#> mtcars$mpg | mtcars$drat | 0.68 | [0.44, 0.83] |  5.10 | < .001
#> 
#> Alternative hypothesis: true correlation is not equal to 0

Which report then relies on to report the test. But model_parameters does not report the variable names for chisq.test objects:

m <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
dimnames(m) <- list(gender = c("F", "M"), party = c("Democrat", "Independent", "Republican"))
x <- chisq.test(m)

parameters::model_parameters(x)
#> Pearson's Chi-squared test
#> 
#> Chi2(2) |      p
#> ----------------
#> 30.07   | < .001

Yet the variable names seem available:

attributes(x$observed)
#> $dim
#> [1] 2 3
#> 
#> $dimnames
#> $dimnames$gender
#> [1] "F" "M"
#> 
#> $dimnames$party
#> [1] "Democrat"    "Independent" "Republican" 
#> 
#> 
#> $class
#> [1] "table"

Fixing this would allow me to fix the current bug with chisq.test objects in report.

report::report(x)
#> Error in UseMethod("interpret"): no applicable method for 'interpret' applied to an object of class "NULL"

Created on 2023-08-27 with reprex v2.0.2

@strengejacke strengejacke added the enhancement 💥 Implemented features can be improved or revised label Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 💥 Implemented features can be improved or revised
Projects
None yet
Development

No branches or pull requests

2 participants