Skip to content

Commit 9ebe2e6

Browse files
minor
1 parent 95905b2 commit 9ebe2e6

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

NEWS.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
# correlation 0.x.x
2-
3-
## Changes
4-
5-
- Don't error if less than 3 valid observations ([#100](https://github.com/easystats/correlation/issues/100))
6-
71
# correlation 0.4.0
82

93
## Changes
104

5+
- Don't error if less than 3 valid observations ([#100](https://github.com/easystats/correlation/issues/100))
116
- Add "gaussian" rank method
127
- Add "gamma" method
138
- Add "hoeffding" method

R/cor_test_biserial.R

+11-17
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,34 @@
1818
}
1919
data[[binary]] <- as.vector((data[[binary]] - min(data[[binary]], na.rm = TRUE)) / diff(range(data[[binary]], na.rm = TRUE), na.rm = TRUE))
2020

21-
# Get biserial correlation
21+
# Get biserial or point-biserial correlation
2222
if (method == "biserial") {
2323
out <- .cor_test_biserial_biserial(data, x, y, continuous, binary, ci)
24-
25-
# Get point-biserial correlation
2624
} else {
27-
out <- .cor_test_freq(data, continuous, binary, ci = ci, method = "pearson", ...)
28-
names(out)[names(out) == "r"] <- "rho"
29-
out$Parameter1 <- x
30-
out$Parameter2 <- y
31-
out$Method <- "Point-biserial"
25+
out <- .cor_test_biserial_pointbiserial(data, x, y, continuous, binary, ci, ...)
3226
}
3327

3428
out
3529
}
3630

3731

3832

33+
#' @keywords internal
34+
.cor_test_biserial_pointbiserial <- function(data, x, y, continuous, binary, ci, ...) {
3935

36+
out <- .cor_test_freq(data, continuous, binary, ci = ci, method = "pearson", ...)
37+
names(out)[names(out) == "r"] <- "rho"
38+
out$Parameter1 <- x
39+
out$Parameter2 <- y
40+
out$Method <- "Point-biserial"
4041

41-
42-
43-
44-
45-
46-
42+
out
43+
}
4744

4845

4946

5047
#' @keywords internal
5148
.cor_test_biserial_biserial <- function(data, x, y, continuous, binary, ci) {
52-
if (!requireNamespace("psych", quietly = TRUE)) {
53-
stop("Package `psych` required for biserial correlations. Please install it by running `install.packages('psych').", call. = FALSE)
54-
}
5549

5650
var_x <- .complete_variable_x(data, continuous, binary)
5751
var_y <- .complete_variable_y(data, continuous, binary)

0 commit comments

Comments
 (0)