Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jun 23, 2024
1 parent 8c4401e commit 94aa04d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions R/cohens_g.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,23 @@ cohens_g <- function(x, y = NULL,
insight::format_error("'x' and 'y' must have the same number of levels (minimum 2)")
}
x <- table(x, y)
} else {
if ((nrow(x) < 2) || (ncol(x) != nrow(x))) {
insight::format_error("'x' must be square with at least two rows and columns")
}
} else if ((nrow(x) < 2) || (ncol(x) != nrow(x))) {
insight::format_error("'x' must be square with at least two rows and columns")
}


b <- x[upper.tri(x)]
c <- t(x)[upper.tri(x)]
a <- x[upper.tri(x)]
b <- t(x)[upper.tri(x)]

P <- sum(pmax(b, c)) / (sum(b) + sum(c))
P <- sum(pmax(a, b)) / (sum(a) + sum(b))
g <- P - 0.5

out <- data.frame(Cohens_g = g)

if (.test_ci(ci)) {
out$CI <- ci

n <- sum(b) + sum(c)
n <- sum(a) + sum(b)
k <- P * n

res <- stats::prop.test(k, n,
Expand Down

0 comments on commit 94aa04d

Please sign in to comment.