From bfcb801c540863a0c424cbbd27310a5838c23c26 Mon Sep 17 00:00:00 2001 From: olivroy <52606734+olivroy@users.noreply.github.com> Date: Sun, 8 Sep 2024 09:30:15 -0400 Subject: [PATCH] Fix partial matching (#321) --- R/cor_test_distance.R | 2 +- R/cor_text.R | 2 +- tests/testthat/test-cor_test.R | 6 +++--- tests/testthat/test-cor_test_na_present.R | 4 ++-- tests/testthat/test-misc.R | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/cor_test_distance.R b/R/cor_test_distance.R index da35cb8a..a5e2f36c 100644 --- a/R/cor_test_distance.R +++ b/R/cor_test_distance.R @@ -12,7 +12,7 @@ CI_low = rez$CI_low, CI_high = rez$CI_high, t = rez$t, - df_error = rez$df, + df_error = rez$df_error, p = rez$p, Method = "Distance (Bias Corrected)", stringsAsFactors = FALSE diff --git a/R/cor_text.R b/R/cor_text.R index fa3d0ded..35cf269e 100644 --- a/R/cor_text.R +++ b/R/cor_text.R @@ -54,7 +54,7 @@ cor_text <- function(x, show_ci = TRUE, show_statistic = TRUE, show_sig = TRUE, out_text <- paste0( out_text, ", t(", - insight::format_value(x$df, protect_integers = TRUE), + insight::format_value(x$df_error, protect_integers = TRUE), ") = ", insight::format_value(x$t) ) diff --git a/tests/testthat/test-cor_test.R b/tests/testthat/test-cor_test.R index 60e1fafd..a9248b4d 100644 --- a/tests/testthat/test-cor_test.R +++ b/tests/testthat/test-cor_test.R @@ -17,7 +17,7 @@ test_that("cor_test kendall", { test_that("cor_test bayesian", { skip_if_not_or_load_if_installed("BayesFactor") out <- cor_test(iris, "Petal.Length", "Petal.Width", bayesian = TRUE) - expect_equal(out$r, 0.9591191, tolerance = 0.01) + expect_equal(out$rho, 0.9591191, tolerance = 0.01) set.seed(123) df_1 <- cor_test(iris, "Petal.Length", "Petal.Width", bayesian = TRUE) @@ -121,7 +121,7 @@ test_that("cor_test percentage", { test_that("cor_test shepherd", { set.seed(333) out <- cor_test(iris, "Petal.Length", "Petal.Width", method = "shepherd") - expect_equal(out$r, 0.94762, tolerance = 0.01) + expect_equal(out$rho, 0.94762, tolerance = 0.01) skip_if_not_or_load_if_installed("BayesFactor") set.seed(333) @@ -164,7 +164,7 @@ test_that("cor_test gaussian", { expect_equal(out$r, 0.87137, tolerance = 0.01) out <- cor_test(iris, "Petal.Length", "Petal.Width", method = "gaussian", bayesian = TRUE) - expect_equal(out$r, 0.8620878, tolerance = 0.01) + expect_equal(out$rho, 0.8620878, tolerance = 0.01) }) diff --git a/tests/testthat/test-cor_test_na_present.R b/tests/testthat/test-cor_test_na_present.R index 5f8d6502..e3cb382f 100644 --- a/tests/testthat/test-cor_test_na_present.R +++ b/tests/testthat/test-cor_test_na_present.R @@ -22,7 +22,7 @@ test_that("cor_test bayesian", { set.seed(123) out <- cor_test(ggplot2::msleep, "brainwt", "sleep_rem", bayesian = TRUE) - expect_equal(out$r, -0.1947696, tolerance = 0.01) + expect_equal(out$rho, -0.1947696, tolerance = 0.01) }) test_that("cor_test tetrachoric", { @@ -122,7 +122,7 @@ test_that("cor_test gaussian", { skip_if_not_or_load_if_installed("BayesFactor") out <- cor_test(ggplot2::msleep, "brainwt", "sleep_rem", method = "gaussian", bayesian = TRUE) - expect_equal(out$r, -0.3269572, tolerance = 0.01) + expect_equal(out$rho, -0.3269572, tolerance = 0.01) }) diff --git a/tests/testthat/test-misc.R b/tests/testthat/test-misc.R index bca19e4e..2ad6bd86 100644 --- a/tests/testthat/test-misc.R +++ b/tests/testthat/test-misc.R @@ -1,7 +1,7 @@ test_that("cor_to_cov", { cor <- cor(iris[1:4]) cov <- cov(iris[1:4]) - cov2 <- cor_to_cov(cor, var = sapply(iris[1:4], var)) + cov2 <- cor_to_cov(cor, variance = sapply(iris[1:4], var)) expect_equal(max(cov - cov2), 0, tolerance = 0.0001) })