From e860d5b0888d4a13fd41db663e2ca1c44bf772ff Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 7 Oct 2022 11:45:08 +0200 Subject: [PATCH] `{correlation}` bug is causing `{ggstatsplot}` check failures Fixes #269 (#270) --- DESCRIPTION | 2 +- NEWS.md | 4 +++- R/cor_smooth.R | 2 +- R/cor_test_bayes.R | 4 ++++ cran-comments.md | 2 ++ tests/testthat/test-as.list.R | 2 -- tests/testthat/test-correlation.R | 11 ++++++++++- tests/testthat/test-display_print_dataframe.R | 3 +-- tests/testthat/test-display_print_matrix.R | 4 ++-- tests/testthat/test-methods.R | 1 - tests/testthat/test-renaming.R | 2 -- tests/testthat/test-selecting_variables.R | 1 - 12 files changed, 24 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 673ec6c7..2ff8927a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: correlation Title: Methods for Correlation Analysis -Version: 0.8.2.4 +Version: 0.8.3 Authors@R: c(person(given = "Dominique", family = "Makowski", diff --git a/NEWS.md b/NEWS.md index 2a93905a..415898d3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# correlation (development version) +# correlation 0.8.3 ## Breaking Changes @@ -8,6 +8,8 @@ ## Minor Changes +- Fixes breakages caused by updates to *parameters* package (#269). + - The visualization recipe (plots) for redundant correlation matrices was improved, so self-correlations will no longer be labelled and get a neutral color. diff --git a/R/cor_smooth.R b/R/cor_smooth.R index 25da44f9..12993854 100644 --- a/R/cor_smooth.R +++ b/R/cor_smooth.R @@ -132,7 +132,7 @@ is_positive_definite <- is.positive_definite is.positive_definite.matrix <- function(x, tol = 10^-12, ...) { eigens <- try(eigen(x), silent = TRUE) - # Sanity checks + # validation checks if (inherits(eigens, as.character("try-error"))) { stop(insight::format_message( "There is something seriously wrong with the correlation matrix, as some of the eigen values are NA." diff --git a/R/cor_test_bayes.R b/R/cor_test_bayes.R index 782444bc..a3403ba1 100644 --- a/R/cor_test_bayes.R +++ b/R/cor_test_bayes.R @@ -89,6 +89,10 @@ rope_ci = 1, ... ) + # validation check: do we have a BF column? + if (is.null(params$BF)) { + params$BF <- NA + } } # Rename coef diff --git a/cran-comments.md b/cran-comments.md index 3228dbd7..53e149cc 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -2,6 +2,8 @@ 0 errors | 0 warnings | 0 notes +- Fixes breakages caused by updates to *parameters* package. + ## revdepcheck results We checked 8 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. diff --git a/tests/testthat/test-as.list.R b/tests/testthat/test-as.list.R index 11915dd2..25bf2573 100644 --- a/tests/testthat/test-as.list.R +++ b/tests/testthat/test-as.list.R @@ -1,7 +1,5 @@ if (require("poorman", quietly = TRUE) && require("ggplot2", quietly = TRUE)) { test_that("as.list", { - skip_if(getRversion() < "3.6") - # no groups set.seed(123) expect_snapshot(as.list(correlation(mtcars))) diff --git a/tests/testthat/test-correlation.R b/tests/testthat/test-correlation.R index f0d0f184..bd6ba476 100644 --- a/tests/testthat/test-correlation.R +++ b/tests/testthat/test-correlation.R @@ -177,9 +177,18 @@ test_that("specific types", { correlation(data, method = "polychoric") }) +test_that("correlation doesn't fail when BFs are NA", { + skip_if_not_installed("BayesFactor") + loadNamespace("BayesFactor") + df <- ggplot2::msleep + + set.seed(123) + df_corr <- correlation(subset(df, vore == "carni"), bayesian = TRUE) + expect_equal(nrow(df_corr), 15L) +}) + test_that("as.data.frame for correlation output", { skip_on_cran() - skip_if(getRversion() < "3.6") set.seed(123) expect_snapshot(as.data.frame(correlation(ggplot2::msleep))) diff --git a/tests/testthat/test-display_print_dataframe.R b/tests/testthat/test-display_print_dataframe.R index 54897894..93944496 100644 --- a/tests/testthat/test-display_print_dataframe.R +++ b/tests/testthat/test-display_print_dataframe.R @@ -3,7 +3,7 @@ if (require("gt") && packageVersion("insight") >= "0.12.0.1") { test_that("display and print method works - markdown", { skip_on_cran() - skip_if(getRversion() < "3.6") + expect_equal( display(correlation(iris)), @@ -29,7 +29,6 @@ if (require("gt") && packageVersion("insight") >= "0.12.0.1") { # display and print method works - HTML ----------------------------- test_that("display and print method works - HTML", { - skip_if(getRversion() < "3.6") skip_on_cran() expect_output(display(print(correlation(subset(mtcars, select = c("wt", "mpg"))), format = "html"))) diff --git a/tests/testthat/test-display_print_matrix.R b/tests/testthat/test-display_print_matrix.R index 2204d372..19b974c5 100644 --- a/tests/testthat/test-display_print_matrix.R +++ b/tests/testthat/test-display_print_matrix.R @@ -3,7 +3,7 @@ if (require("testthat") && require("gt") && require("poorman")) { test_that("display and print method works - markdown", { skip_on_cran() - skip_if(getRversion() < "3.6") + expect_equal( display(summary(correlation(iris))), @@ -32,7 +32,7 @@ if (require("testthat") && require("gt") && require("poorman")) { test_that("display and print method works - html", { skip_on_cran() - skip_if(getRversion() < "3.6") + expect_snapshot(print(summary(correlation(iris)), format = "html"), cran = FALSE) }) diff --git a/tests/testthat/test-methods.R b/tests/testthat/test-methods.R index 84569724..d8f2d354 100644 --- a/tests/testthat/test-methods.R +++ b/tests/testthat/test-methods.R @@ -5,7 +5,6 @@ test_that("as.matrix.correlation", { }) test_that("summary.correlation - target column", { - skip_if(getRversion() < "3.6") skip_if_not_installed("ggplot2") expect_snapshot(summary(correlation(ggplot2::msleep), target = "t")) expect_snapshot(summary(correlation(ggplot2::msleep), target = "df_error")) diff --git a/tests/testthat/test-renaming.R b/tests/testthat/test-renaming.R index 7457acd3..2c18eec3 100644 --- a/tests/testthat/test-renaming.R +++ b/tests/testthat/test-renaming.R @@ -1,6 +1,4 @@ test_that("renaming columns", { - skip_if(getRversion() < "3.6") - # should warn the user expect_snapshot(correlation(anscombe, select = c("x1", "x2"), diff --git a/tests/testthat/test-selecting_variables.R b/tests/testthat/test-selecting_variables.R index ef5f593b..8a4be3b0 100644 --- a/tests/testthat/test-selecting_variables.R +++ b/tests/testthat/test-selecting_variables.R @@ -2,7 +2,6 @@ if (require("poorman")) { test_that("selecting specific variables works", { - skip_if(getRversion() < "3.6") set.seed(123) df1 <- mtcars %>%