easystats / easystats/parameters
`model_parameters`: Add variables names for `chisq.test` objects
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 499
- Forks
- 45
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 3
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at model_parameters handling for chisq.test objects and reproduce the issue using the R examples in the report. Inspect how the observed table's dimnames are available, then verify that model_parameters exposes the variable names and that report::report(x) no longer fails with missing parameter information.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100