cor_text() errors for Kendall correlations

Open Beginner friendly
#403 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
r
Domain
data

Research direction

Start in R/cor_text.R and inspect the z branch that reads table$z; the issue says it should read from x. Reproduce the failure with the Kendall examples in the issue, then check the output for both cor_test() and correlation(). Done means cor_text() returns the expected text with the statistic; the issue also raises whether the exact Kendall statistic should be labeled T.

Written by the indexing model from the issue text.

Description

cor_text() fails on any result that has a z column, which is every frequentist Kendall correlation:

library(correlation)
cor_text(cor_test(mtcars, "mpg", "wt", method = "kendall"))
#> Error in table$z : object of type 'closure' is not subsettable

cor_text(correlation(mtcars[1:3], method = "kendall")) fails the same way. The z branch in R/cor_text.R reads table$z where it means x$z.

Expected: the same text as for other methods, with the z statistic.

Related: with exact = TRUE, the z column holds Kendall's exact statistic T, not a z. The printed table already shows z = 36 here, and cor_text() would too once the error is fixed. It should probably be labeled T:

set.seed(2)
a <- rnorm(10)
b <- a + rnorm(10)
cor_test(data.frame(a, b), "a", "b", method = "kendall", exact = TRUE)$z
#> [1] 36
cor.test(a, b, method = "kendall", exact = TRUE)$statistic
#>  T
#> 36
Dominant language
R
Stars
455
Forks
60
Avg merge
1d 20h
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from easystats/correlation

All issues in easystats/correlation

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.