From f8e8fa1f353a273a8e863d7779ec13ab10c8e34c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 18:30:02 +0000 Subject: [PATCH 01/12] Initial plan From d31dcc28a61dcf8e7104aa9abdf1c98a7cec4eac Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 18:36:12 +0000 Subject: [PATCH 02/12] Fix conditional formatting rules to use relative references Co-authored-by: rempsyc <13123390+rempsyc@users.noreply.github.com> --- R/cormatrix_to_excel.R | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/R/cormatrix_to_excel.R b/R/cormatrix_to_excel.R index a4448ef3..a09e3d4a 100644 --- a/R/cormatrix_to_excel.R +++ b/R/cormatrix_to_excel.R @@ -247,37 +247,37 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= .2, r_values!B2 > 0, p_values!B2 < .05)", + rule = "AND(B2 <= .2, B2 > 0, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .05)", style = "one_star_pink" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= .2, p_values!B2 < .05)", + rule = "AND(B2 >= .2, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .05)", style = "one_star_peach" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= .4, p_values!B2 < .05)", + rule = "AND(B2 >= .4, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .05)", style = "one_star_red" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= -.2, r_values!B2 < 0, p_values!B2 < .05)", + rule = "AND(B2 >= -.2, B2 < 0, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .05)", style = "one_star_lightblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= -.2, p_values!B2 < .05)", + rule = "AND(B2 <= -.2, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .05)", style = "one_star_midblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= -.4, p_values!B2 < .05)", + rule = "AND(B2 <= -.4, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .05)", style = "one_star_darkblue" ) @@ -285,37 +285,37 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= .2, r_values!B2 > 0, p_values!B2 < .01)", + rule = "AND(B2 <= .2, B2 > 0, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .01)", style = "two_stars_pink" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= .2, p_values!B2 < .01)", + rule = "AND(B2 >= .2, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .01)", style = "two_stars_peach" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= .4, p_values!B2 < .01)", + rule = "AND(B2 >= .4, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .01)", style = "two_stars_red" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= -.02, r_values!B2 < 0, p_values!B2 < .01)", + rule = "AND(B2 >= -.02, B2 < 0, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .01)", style = "two_stars_lightblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= -.2, p_values!B2 < .01)", + rule = "AND(B2 <= -.2, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .01)", style = "two_stars_midblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= -.4, p_values!B2 < .01)", + rule = "AND(B2 <= -.4, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .01)", style = "two_stars_darkblue" ) @@ -323,37 +323,37 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= .2, r_values!B2 > 0, p_values!B2 < .001)", + rule = "AND(B2 <= .2, B2 > 0, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .001)", style = "three_stars_pink" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= .2, p_values!B2 < .001)", + rule = "AND(B2 >= .2, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .001)", style = "three_stars_peach" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= .4, p_values!B2 < .001)", + rule = "AND(B2 >= .4, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .001)", style = "three_stars_red" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= -.2, r_values!B2 < 0, p_values!B2 < .001)", + rule = "AND(B2 >= -.2, B2 < 0, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .001)", style = "three_stars_lightblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= -.2, p_values!B2 < .001)", + rule = "AND(B2 <= -.2, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .001)", style = "three_stars_midblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= -.4, p_values!B2 < .001)", + rule = "AND(B2 <= -.4, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .001)", style = "three_stars_darkblue" ) @@ -361,13 +361,13 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 = 1)", + rule = "AND(B2 = 1)", style = "gray_style" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(p_values!B2 >= .05)", + rule = "AND(INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) >= .05)", style = "no_star" ) From 93b903c24f30da4351f962f43a7a2cbb98836a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Th=C3=A9riault?= <13123390+rempsyc@users.noreply.github.com> Date: Mon, 17 Nov 2025 14:53:59 -0500 Subject: [PATCH 03/12] document, air, add expect_warning to warning created in: expect_error(cor_test( data, "brainwt_binary", "sleep_rem_binary", method = "tetrachoric" )) --- DESCRIPTION | 2 +- man/cor_smooth.Rd | 2 +- man/cormatrix_to_excel.Rd | 2 +- man/correlation.Rd | 2 +- man/visualisation_recipe.easycormatrix.Rd | 6 +- tests/testthat/_snaps/renaming.md | 12 +-- tests/testthat/test-cor_test_na_present.R | 90 +++++++++++++++++++---- 7 files changed, 88 insertions(+), 28 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7bd16232..4afcc5cd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -88,7 +88,7 @@ VignetteBuilder: knitr Encoding: UTF-8 Language: en-US -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 Roxygen: list(markdown = TRUE) Config/testthat/edition: 3 Config/Needs/website: diff --git a/man/cor_smooth.Rd b/man/cor_smooth.Rd index b2806a48..ddb3fa32 100644 --- a/man/cor_smooth.Rd +++ b/man/cor_smooth.Rd @@ -32,7 +32,7 @@ is done, inferential statistics (\emph{p}-values, confidence intervals, etc.) ar removed, as they are no longer valid. } \examples{ -\dontshow{if (requireNamespace("psych", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("psych", quietly = TRUE)) withAutoprint(\{ # examplesIf} set.seed(123) data <- as.matrix(mtcars) # Make missing data so pairwise correlation matrix is non-positive definite diff --git a/man/cormatrix_to_excel.Rd b/man/cormatrix_to_excel.Rd index ca5ae021..e140ffa6 100644 --- a/man/cormatrix_to_excel.Rd +++ b/man/cormatrix_to_excel.Rd @@ -33,7 +33,7 @@ correlation coefficients colour-coded based on effect size for small (.10), medium (.30), and large (.50) correlation sizes. } \examples{ -\dontshow{if (requireNamespace("openxlsx2", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("openxlsx2", quietly = TRUE)) withAutoprint(\{ # examplesIf} \dontshow{ .old_wd <- setwd(tempdir()) } diff --git a/man/correlation.Rd b/man/correlation.Rd index 69dc1387..7852dbf9 100644 --- a/man/correlation.Rd +++ b/man/correlation.Rd @@ -272,7 +272,7 @@ Bayesian rank correlations (which have different priors). } } \examples{ -\dontshow{if (all(insight::check_if_installed(c("psych", "datawizard"), quietly = TRUE)) && getRversion() >= "4.1.0") (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (all(insight::check_if_installed(c("psych", "datawizard"), quietly = TRUE)) && getRversion() >= "4.1.0") withAutoprint(\{ # examplesIf} library(correlation) data(iris) diff --git a/man/visualisation_recipe.easycormatrix.Rd b/man/visualisation_recipe.easycormatrix.Rd index 453b1308..6ddf9ed4 100644 --- a/man/visualisation_recipe.easycormatrix.Rd +++ b/man/visualisation_recipe.easycormatrix.Rd @@ -61,7 +61,7 @@ the arguments described below. See examples \href{https://easystats.github.io/correlation/reference/visualisation_recipe.easycormatrix.html#ref-examples}{\strong{here}}. } \examples{ -\dontshow{if (require("see")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("see")) withAutoprint(\{ # examplesIf} \donttest{ rez <- cor_test(mtcars, "mpg", "wt") @@ -77,7 +77,7 @@ plot(rez, ) } \dontshow{\}) # examplesIf} -\dontshow{if (require("see")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("see")) withAutoprint(\{ # examplesIf} \donttest{ rez <- correlation(mtcars) @@ -106,7 +106,7 @@ layers <- visualisation_recipe(x, plot(layers) + theme_modern() } \dontshow{\}) # examplesIf} -\dontshow{if (require("see") && require("tidygraph") && require("ggraph")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("see") && require("tidygraph") && require("ggraph")) withAutoprint(\{ # examplesIf} \donttest{ rez <- correlation(iris) diff --git a/tests/testthat/_snaps/renaming.md b/tests/testthat/_snaps/renaming.md index 2fe9f676..9423b06a 100644 --- a/tests/testthat/_snaps/renaming.md +++ b/tests/testthat/_snaps/renaming.md @@ -5,9 +5,9 @@ Output # Correlation Matrix (pearson-method) - Parameter1 | Parameter2 | r | 95% CI | t(9) | p - ---------------------------------------------------------------- - x1 | x2 | 1.00 | [1.00, 1.00] | Inf | < .001*** + Parameter1 | Parameter2 | r | 95% CI | t(9) | p + ------------------------------------------------------------- + x1 | x2 | 1 | [1.00, 1.00] | Inf | < .001*** p-value adjustment method: Holm (1979) Observations: 11 @@ -19,9 +19,9 @@ Output # Correlation Matrix (pearson-method) - Parameter1 | Parameter2 | r | 95% CI | t(9) | p - ---------------------------------------------------------------- - var1 | var2 | 1.00 | [1.00, 1.00] | Inf | < .001*** + Parameter1 | Parameter2 | r | 95% CI | t(9) | p + ------------------------------------------------------------- + var1 | var2 | 1 | [1.00, 1.00] | Inf | < .001*** p-value adjustment method: Holm (1979) Observations: 11 diff --git a/tests/testthat/test-cor_test_na_present.R b/tests/testthat/test-cor_test_na_present.R index 8449c265..1a17a3ac 100644 --- a/tests/testthat/test-cor_test_na_present.R +++ b/tests/testthat/test-cor_test_na_present.R @@ -11,7 +11,11 @@ test_that("cor_test kendall", { skip_if_not_or_load_if_installed("ggplot2") out <- cor_test(ggplot2::msleep, "brainwt", "sleep_rem", method = "kendall") - out2 <- suppressWarnings(stats::cor.test(ggplot2::msleep$brainwt, ggplot2::msleep$sleep_rem, method = "kendall")) + out2 <- suppressWarnings(stats::cor.test( + ggplot2::msleep$brainwt, + ggplot2::msleep$sleep_rem, + method = "kendall" + )) expect_equal(out$tau, out2$estimate[[1]], tolerance = 0.001) expect_equal(out$p, out2$p.value[[1]], tolerance = 0.001) @@ -35,26 +39,58 @@ test_that("cor_test tetrachoric", { data$sleep_rem_binary <- as.numeric(data$sleep_rem > 1.2) # With Factors / Binary - expect_error(cor_test(data, "brainwt_binary", "sleep_rem_binary", method = "tetrachoric")) + expect_warning(expect_error(cor_test( + data, + "brainwt_binary", + "sleep_rem_binary", + method = "tetrachoric" + ))) data$sleep_rem_ordinal <- as.factor(round(data$sleep_rem)) data$brainwt_ordinal <- as.factor(round(data$brainwt)) - out <- suppressWarnings(cor_test(data, "brainwt", "brainwt_ordinal", method = "polychoric")) + out <- suppressWarnings(cor_test( + data, + "brainwt", + "brainwt_ordinal", + method = "polychoric" + )) expect_equal(out$rho, 0.9999, tolerance = 0.01) # Biserial - expect_error(cor_test(data, "brainwt", "sleep_rem_binary", method = "pointbiserial")) - - expect_error(cor_test(data, "brainwt", "sleep_rem_binary", method = "biserial")) + expect_error(cor_test( + data, + "brainwt", + "sleep_rem_binary", + method = "pointbiserial" + )) + + expect_error(cor_test( + data, + "brainwt", + "sleep_rem_binary", + method = "biserial" + )) }) test_that("cor_test robust", { skip_if_not_or_load_if_installed("ggplot2") - out1 <- cor_test(ggplot2::msleep, "brainwt", "sleep_rem", method = "pearson", ranktransform = TRUE) - out2 <- cor_test(ggplot2::msleep, "brainwt", "sleep_rem", method = "spearman", ranktransform = FALSE) + out1 <- cor_test( + ggplot2::msleep, + "brainwt", + "sleep_rem", + method = "pearson", + ranktransform = TRUE + ) + out2 <- cor_test( + ggplot2::msleep, + "brainwt", + "sleep_rem", + method = "spearman", + ranktransform = FALSE + ) expect_equal(out1$r, out2$rho, tolerance = 0.01) }) @@ -75,7 +111,12 @@ test_that("cor_test percentage", { skip_if_not_or_load_if_installed("ggplot2") skip_if_not_or_load_if_installed("WRS2") - out <- cor_test(ggplot2::msleep, "brainwt", "sleep_rem", method = "percentage") + out <- cor_test( + ggplot2::msleep, + "brainwt", + "sleep_rem", + method = "percentage" + ) comparison <- WRS2::pbcor(ggplot2::msleep$brainwt, ggplot2::msleep$sleep_rem) expect_equal(out$r, as.numeric(comparison$cor), tolerance = 0.01) }) @@ -85,7 +126,12 @@ test_that("cor_test shepherd", { skip_if_not_or_load_if_installed("ggplot2") set.seed(333) - expect_error(cor_test(ggplot2::msleep, "brainwt", "sleep_rem", method = "shepherd")) + expect_error(cor_test( + ggplot2::msleep, + "brainwt", + "sleep_rem", + method = "shepherd" + )) }) @@ -121,19 +167,33 @@ test_that("cor_test gaussian", { expect_equal(out$r, -0.3679795, tolerance = 0.01) skip_if_not_or_load_if_installed("BayesFactor") - out <- cor_test(ggplot2::msleep, "brainwt", "sleep_rem", method = "gaussian", bayesian = TRUE) + out <- cor_test( + ggplot2::msleep, + "brainwt", + "sleep_rem", + method = "gaussian", + bayesian = TRUE + ) expect_equal(out$rho, -0.3269572, tolerance = 0.01) }) # Additional arguments ---------------------------------------------------- - test_that("cor_test one-sided p value", { skip_if_not_or_load_if_installed("ggplot2") - baseline <- cor.test(ggplot2::msleep$brainwt, ggplot2::msleep$sleep_rem, alternative = "greater") - - out <- cor_test(ggplot2::msleep, "brainwt", "sleep_rem", alternative = "greater") + baseline <- cor.test( + ggplot2::msleep$brainwt, + ggplot2::msleep$sleep_rem, + alternative = "greater" + ) + + out <- cor_test( + ggplot2::msleep, + "brainwt", + "sleep_rem", + alternative = "greater" + ) expect_equal(out$p, baseline$p.value, tolerance = 0.000001) }) From 4732ab0789d41f7fb7833b83c477b125fcb1fb79 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 20:29:53 +0000 Subject: [PATCH 04/12] Use INDEX instead of INDIRECT for cross-sheet references in conditional formatting Co-authored-by: rempsyc <13123390+rempsyc@users.noreply.github.com> --- R/cormatrix_to_excel.R | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/R/cormatrix_to_excel.R b/R/cormatrix_to_excel.R index a09e3d4a..2acf525d 100644 --- a/R/cormatrix_to_excel.R +++ b/R/cormatrix_to_excel.R @@ -247,37 +247,37 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= .2, B2 > 0, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .05)", + rule = "AND(B2 <= .2, B2 > 0, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .05)", style = "one_star_pink" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= .2, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .05)", + rule = "AND(B2 >= .2, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .05)", style = "one_star_peach" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= .4, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .05)", + rule = "AND(B2 >= .4, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .05)", style = "one_star_red" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= -.2, B2 < 0, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .05)", + rule = "AND(B2 >= -.2, B2 < 0, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .05)", style = "one_star_lightblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= -.2, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .05)", + rule = "AND(B2 <= -.2, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .05)", style = "one_star_midblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= -.4, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .05)", + rule = "AND(B2 <= -.4, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .05)", style = "one_star_darkblue" ) @@ -285,37 +285,37 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= .2, B2 > 0, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .01)", + rule = "AND(B2 <= .2, B2 > 0, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .01)", style = "two_stars_pink" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= .2, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .01)", + rule = "AND(B2 >= .2, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .01)", style = "two_stars_peach" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= .4, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .01)", + rule = "AND(B2 >= .4, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .01)", style = "two_stars_red" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= -.02, B2 < 0, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .01)", + rule = "AND(B2 >= -.02, B2 < 0, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .01)", style = "two_stars_lightblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= -.2, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .01)", + rule = "AND(B2 <= -.2, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .01)", style = "two_stars_midblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= -.4, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .01)", + rule = "AND(B2 <= -.4, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .01)", style = "two_stars_darkblue" ) @@ -323,37 +323,37 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= .2, B2 > 0, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .001)", + rule = "AND(B2 <= .2, B2 > 0, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .001)", style = "three_stars_pink" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= .2, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .001)", + rule = "AND(B2 >= .2, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .001)", style = "three_stars_peach" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= .4, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .001)", + rule = "AND(B2 >= .4, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .001)", style = "three_stars_red" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= -.2, B2 < 0, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .001)", + rule = "AND(B2 >= -.2, B2 < 0, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .001)", style = "three_stars_lightblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= -.2, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .001)", + rule = "AND(B2 <= -.2, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .001)", style = "three_stars_midblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= -.4, INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) < .001)", + rule = "AND(B2 <= -.4, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .001)", style = "three_stars_darkblue" ) @@ -367,7 +367,7 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(INDIRECT(\"p_values!\"&ADDRESS(ROW(),COLUMN())) >= .05)", + rule = "AND(INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) >= .05)", style = "no_star" ) From 4d5e9af120a37cc99cc9f9c528c22fc42f39499d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:11:46 +0000 Subject: [PATCH 05/12] Revert formula changes and fix by reordering conditional formatting rules The issue was not with cell references but with the order of rules. In openxlsx2 v1.21, conditional formatting is applied in a waterfall where the first matching rule wins. Previously rules were applied in reverse order. Solution: Apply most specific rules first (three stars before two stars before one star). Co-authored-by: rempsyc <13123390+rempsyc@users.noreply.github.com> --- R/cormatrix_to_excel.R | 87 +++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/R/cormatrix_to_excel.R b/R/cormatrix_to_excel.R index 2acf525d..f542dcd2 100644 --- a/R/cormatrix_to_excel.R +++ b/R/cormatrix_to_excel.R @@ -241,148 +241,149 @@ cormatrix_to_excel <- function(data, wb$add_worksheet("p_values")$add_data(x = p_val) # create conditional formatting for the stars (as well as colours as we have no) - # one star # Compute the cell range for styling dims_fmt <- openxlsx2::wb_dims(cols = all.columns, rows = all.columns) + + # three stars (most specific, applied first so it wins for p < .001) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= .2, B2 > 0, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .05)", - style = "one_star_pink" + rule = "AND(r_values!B2 <= .2, r_values!B2 > 0, p_values!B2 < .001)", + style = "three_stars_pink" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= .2, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .05)", - style = "one_star_peach" + rule = "AND(r_values!B2 >= .2, p_values!B2 < .001)", + style = "three_stars_peach" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= .4, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .05)", - style = "one_star_red" + rule = "AND(r_values!B2 >= .4, p_values!B2 < .001)", + style = "three_stars_red" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= -.2, B2 < 0, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .05)", - style = "one_star_lightblue" + rule = "AND(r_values!B2 >= -.2, r_values!B2 < 0, p_values!B2 < .001)", + style = "three_stars_lightblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= -.2, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .05)", - style = "one_star_midblue" + rule = "AND(r_values!B2 <= -.2, p_values!B2 < .001)", + style = "three_stars_midblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= -.4, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .05)", - style = "one_star_darkblue" + rule = "AND(r_values!B2 <= -.4, p_values!B2 < .001)", + style = "three_stars_darkblue" ) # two stars wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= .2, B2 > 0, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .01)", + rule = "AND(r_values!B2 <= .2, r_values!B2 > 0, p_values!B2 < .01)", style = "two_stars_pink" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= .2, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .01)", + rule = "AND(r_values!B2 >= .2, p_values!B2 < .01)", style = "two_stars_peach" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= .4, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .01)", + rule = "AND(r_values!B2 >= .4, p_values!B2 < .01)", style = "two_stars_red" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= -.02, B2 < 0, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .01)", + rule = "AND(r_values!B2 >= -.02, r_values!B2 < 0, p_values!B2 < .01)", style = "two_stars_lightblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= -.2, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .01)", + rule = "AND(r_values!B2 <= -.2, p_values!B2 < .01)", style = "two_stars_midblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= -.4, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .01)", + rule = "AND(r_values!B2 <= -.4, p_values!B2 < .01)", style = "two_stars_darkblue" ) - # three stars + # one star wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= .2, B2 > 0, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .001)", - style = "three_stars_pink" + rule = "AND(r_values!B2 <= .2, r_values!B2 > 0, p_values!B2 < .05)", + style = "one_star_pink" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= .2, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .001)", - style = "three_stars_peach" + rule = "AND(r_values!B2 >= .2, p_values!B2 < .05)", + style = "one_star_peach" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= .4, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .001)", - style = "three_stars_red" + rule = "AND(r_values!B2 >= .4, p_values!B2 < .05)", + style = "one_star_red" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 >= -.2, B2 < 0, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .001)", - style = "three_stars_lightblue" + rule = "AND(r_values!B2 >= -.2, r_values!B2 < 0, p_values!B2 < .05)", + style = "one_star_lightblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= -.2, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .001)", - style = "three_stars_midblue" + rule = "AND(r_values!B2 <= -.2, p_values!B2 < .05)", + style = "one_star_midblue" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 <= -.4, INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) < .001)", - style = "three_stars_darkblue" + rule = "AND(r_values!B2 <= -.4, p_values!B2 < .05)", + style = "one_star_darkblue" ) # Other formatting wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(B2 = 1)", + rule = "AND(r_values!B2 = 1)", style = "gray_style" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(INDEX(p_values!$B:$ZZ, ROW(), COLUMN()) >= .05)", + rule = "AND(p_values!B2 >= .05)", style = "no_star" ) - # p-values + # p-values (most specific first) wb$add_conditional_formatting( "p_values", dims = dims_fmt, - rule = "< 10", - style = "p_style" + rule = "== 0", + style = "gray_style" ) wb$add_conditional_formatting( "p_values", dims = dims_fmt, - rule = "< .05", - style = "p_style1" + rule = "< .001", + style = "p_style3" ) wb$add_conditional_formatting( "p_values", @@ -393,14 +394,14 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "p_values", dims = dims_fmt, - rule = "< .001", - style = "p_style3" + rule = "< .05", + style = "p_style1" ) wb$add_conditional_formatting( "p_values", dims = dims_fmt, - rule = "== 0", - style = "gray_style" + rule = "< 10", + style = "p_style" ) ## Freeze Panes From b56024ae556edebec85c56fbfe9a4f26dee4f3f7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:24:20 +0000 Subject: [PATCH 06/12] Fix gray diagonal formatting by moving it to first position The gray diagonal rule (r_values = 1) must be the FIRST rule applied so it wins for diagonal cells. Previously it was after all the star rules, causing diagonal cells to show stars instead of gray. Co-authored-by: rempsyc <13123390+rempsyc@users.noreply.github.com> --- R/cormatrix_to_excel.R | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/R/cormatrix_to_excel.R b/R/cormatrix_to_excel.R index f542dcd2..c6d3476e 100644 --- a/R/cormatrix_to_excel.R +++ b/R/cormatrix_to_excel.R @@ -244,7 +244,15 @@ cormatrix_to_excel <- function(data, # Compute the cell range for styling dims_fmt <- openxlsx2::wb_dims(cols = all.columns, rows = all.columns) - # three stars (most specific, applied first so it wins for p < .001) + # gray diagonal (most specific, must be first to win for r = 1) + wb$add_conditional_formatting( + "r_values", + dims = dims_fmt, + rule = "AND(r_values!B2 = 1)", + style = "gray_style" + ) + + # three stars (applied second for p < .001) wb$add_conditional_formatting( "r_values", dims = dims_fmt, @@ -358,13 +366,7 @@ cormatrix_to_excel <- function(data, style = "one_star_darkblue" ) - # Other formatting - wb$add_conditional_formatting( - "r_values", - dims = dims_fmt, - rule = "AND(r_values!B2 = 1)", - style = "gray_style" - ) + # no stars (for non-significant correlations) wb$add_conditional_formatting( "r_values", dims = dims_fmt, From aa3db34c60c214a948971d7566c2f508986bedd3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:30:28 +0000 Subject: [PATCH 07/12] Fix color ordering within each significance level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Within each significance level (three/two/one star), the most specific color rules must come first. For positive: red (≥.4) before peach (≥.2) before pink (≤.2). For negative: darkblue (≤-.4) before midblue (≤-.2) before lightblue (≥-.2). This ensures correct colors based on correlation strength in the waterfall application order. Co-authored-by: rempsyc <13123390+rempsyc@users.noreply.github.com> --- R/cormatrix_to_excel.R | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/R/cormatrix_to_excel.R b/R/cormatrix_to_excel.R index c6d3476e..913f8bde 100644 --- a/R/cormatrix_to_excel.R +++ b/R/cormatrix_to_excel.R @@ -252,12 +252,12 @@ cormatrix_to_excel <- function(data, style = "gray_style" ) - # three stars (applied second for p < .001) + # three stars (p < .001) - most specific color ranges first wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= .2, r_values!B2 > 0, p_values!B2 < .001)", - style = "three_stars_pink" + rule = "AND(r_values!B2 >= .4, p_values!B2 < .001)", + style = "three_stars_red" ) wb$add_conditional_formatting( "r_values", @@ -268,14 +268,14 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= .4, p_values!B2 < .001)", - style = "three_stars_red" + rule = "AND(r_values!B2 <= .2, r_values!B2 > 0, p_values!B2 < .001)", + style = "three_stars_pink" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= -.2, r_values!B2 < 0, p_values!B2 < .001)", - style = "three_stars_lightblue" + rule = "AND(r_values!B2 <= -.4, p_values!B2 < .001)", + style = "three_stars_darkblue" ) wb$add_conditional_formatting( "r_values", @@ -286,16 +286,16 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= -.4, p_values!B2 < .001)", - style = "three_stars_darkblue" + rule = "AND(r_values!B2 >= -.2, r_values!B2 < 0, p_values!B2 < .001)", + style = "three_stars_lightblue" ) - # two stars + # two stars (p < .01) - most specific color ranges first wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= .2, r_values!B2 > 0, p_values!B2 < .01)", - style = "two_stars_pink" + rule = "AND(r_values!B2 >= .4, p_values!B2 < .01)", + style = "two_stars_red" ) wb$add_conditional_formatting( "r_values", @@ -306,14 +306,14 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= .4, p_values!B2 < .01)", - style = "two_stars_red" + rule = "AND(r_values!B2 <= .2, r_values!B2 > 0, p_values!B2 < .01)", + style = "two_stars_pink" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= -.02, r_values!B2 < 0, p_values!B2 < .01)", - style = "two_stars_lightblue" + rule = "AND(r_values!B2 <= -.4, p_values!B2 < .01)", + style = "two_stars_darkblue" ) wb$add_conditional_formatting( "r_values", @@ -324,16 +324,16 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= -.4, p_values!B2 < .01)", - style = "two_stars_darkblue" + rule = "AND(r_values!B2 >= -.2, r_values!B2 < 0, p_values!B2 < .01)", + style = "two_stars_lightblue" ) - # one star + # one star (p < .05) - most specific color ranges first wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= .2, r_values!B2 > 0, p_values!B2 < .05)", - style = "one_star_pink" + rule = "AND(r_values!B2 >= .4, p_values!B2 < .05)", + style = "one_star_red" ) wb$add_conditional_formatting( "r_values", @@ -344,14 +344,14 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= .4, p_values!B2 < .05)", - style = "one_star_red" + rule = "AND(r_values!B2 <= .2, r_values!B2 > 0, p_values!B2 < .05)", + style = "one_star_pink" ) wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 >= -.2, r_values!B2 < 0, p_values!B2 < .05)", - style = "one_star_lightblue" + rule = "AND(r_values!B2 <= -.4, p_values!B2 < .05)", + style = "one_star_darkblue" ) wb$add_conditional_formatting( "r_values", @@ -362,8 +362,8 @@ cormatrix_to_excel <- function(data, wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 <= -.4, p_values!B2 < .05)", - style = "one_star_darkblue" + rule = "AND(r_values!B2 >= -.2, r_values!B2 < 0, p_values!B2 < .05)", + style = "one_star_lightblue" ) # no stars (for non-significant correlations) From 9eb3d37d499f3e30b456d3fbc11466d23c95734f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Th=C3=A9riault?= <13123390+rempsyc@users.noreply.github.com> Date: Tue, 18 Nov 2025 14:45:57 -0500 Subject: [PATCH 08/12] air format --- R/cormatrix_to_excel.R | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/R/cormatrix_to_excel.R b/R/cormatrix_to_excel.R index 913f8bde..dc152ef6 100644 --- a/R/cormatrix_to_excel.R +++ b/R/cormatrix_to_excel.R @@ -41,13 +41,17 @@ #' \dontshow{ #' setwd(.old_wd) #' } -cormatrix_to_excel <- function(data, - filename, - overwrite = TRUE, - print.mat = TRUE, - ...) { +cormatrix_to_excel <- function( + data, + filename, + overwrite = TRUE, + print.mat = TRUE, + ... +) { if (missing(filename)) { - insight::format_error("Argument 'filename' required (as per CRAN policies).") + insight::format_error( + "Argument 'filename' required (as per CRAN policies)." + ) } insight::check_if_installed("openxlsx2") @@ -243,7 +247,7 @@ cormatrix_to_excel <- function(data, # create conditional formatting for the stars (as well as colours as we have no) # Compute the cell range for styling dims_fmt <- openxlsx2::wb_dims(cols = all.columns, rows = all.columns) - + # gray diagonal (most specific, must be first to win for r = 1) wb$add_conditional_formatting( "r_values", @@ -251,7 +255,7 @@ cormatrix_to_excel <- function(data, rule = "AND(r_values!B2 = 1)", style = "gray_style" ) - + # three stars (p < .001) - most specific color ranges first wb$add_conditional_formatting( "r_values", @@ -412,7 +416,8 @@ cormatrix_to_excel <- function(data, # Save Excel cat(paste0( - "\n\n [Correlation matrix '", filename, + "\n\n [Correlation matrix '", + filename, ".xlsx' has been saved to working directory (or where specified).]" )) openxlsx2::wb_save(wb, file = paste0(filename, ".xlsx"), overwrite = TRUE) From ec578407afc45ace236d5061c38834744cad52e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Th=C3=A9riault?= <13123390+rempsyc@users.noreply.github.com> Date: Wed, 19 Nov 2025 13:23:52 -0500 Subject: [PATCH 09/12] bump version [skip ci] --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4afcc5cd..de86ddb5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: correlation Title: Methods for Correlation Analysis -Version: 0.8.8 +Version: 0.8.8.1 Authors@R: c(person(given = "Dominique", family = "Makowski", From fb004b6cf48839bf00202610ed8d943bcb692443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Th=C3=A9riault?= <13123390+rempsyc@users.noreply.github.com> Date: Wed, 19 Nov 2025 13:25:14 -0500 Subject: [PATCH 10/12] news [skip ci] --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index c9759e1c..a28e0905 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# correlation 0.8.9 + +- + # correlation 0.8.8 - `correlation()` gains a `missing=` argument, similar to `stats::cor(use=)`, for controlling how missing data is handled. From d9cae0c82a934920e9e9235598f14861531f6515 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Nov 2025 18:29:34 +0000 Subject: [PATCH 11/12] Remove unnecessary AND() wrapper and update NEWS.md - Removed unnecessary AND() wrapper from gray diagonal rule (only one condition) - Updated NEWS.md with bug fix entry for cormatrix_to_excel() compatibility with openxlsx2 v1.21+ Co-authored-by: rempsyc <13123390+rempsyc@users.noreply.github.com> --- NEWS.md | 11 ++++++++++- R/cormatrix_to_excel.R | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index a28e0905..db8929a4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,15 @@ # correlation 0.8.9 -- +## Bug Fixes + +- `cormatrix_to_excel()` now works correctly with openxlsx2 v1.21+. Fixed + conditional formatting rule ordering to accommodate the new waterfall + application mode where the first matching rule wins (previously rules were + applied in reverse order). All formatting rules are now ordered from most + to least specific to ensure correct display of significance stars, colors, + and diagonal formatting (#361). + + # correlation 0.8.8 diff --git a/R/cormatrix_to_excel.R b/R/cormatrix_to_excel.R index dc152ef6..d383b5aa 100644 --- a/R/cormatrix_to_excel.R +++ b/R/cormatrix_to_excel.R @@ -252,7 +252,7 @@ cormatrix_to_excel <- function( wb$add_conditional_formatting( "r_values", dims = dims_fmt, - rule = "AND(r_values!B2 = 1)", + rule = "r_values!B2 = 1", style = "gray_style" ) From a1537abf6912c89fb433be805a73e7284e3a7b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Th=C3=A9riault?= <13123390+rempsyc@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:55:16 -0500 Subject: [PATCH 12/12] news [skip ci] --- NEWS.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index db8929a4..e583219f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,14 +2,9 @@ ## Bug Fixes -- `cormatrix_to_excel()` now works correctly with openxlsx2 v1.21+. Fixed - conditional formatting rule ordering to accommodate the new waterfall - application mode where the first matching rule wins (previously rules were - applied in reverse order). All formatting rules are now ordered from most - to least specific to ensure correct display of significance stars, colors, - and diagonal formatting (#361). - - +- `cormatrix_to_excel()` now works correctly with openxlsx2 v1.16+. Fixed + conditional formatting rule ordering to accommodate openxlsx2's new waterfall + strategy (#361). # correlation 0.8.8