Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jan 3, 2025
1 parent 5b3622c commit f11f915
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/methods_format.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ format.easycormatrix <- function(x,
stars = NULL,
include_significance = NULL,
format = NULL,
zap_small = TRUE,
zap_small = NULL,
bf_exact = TRUE,
...) {
# If it's a real matrix
Expand Down
28 changes: 28 additions & 0 deletions tests/testthat/_snaps/windows/correlation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# correlation output with zap_small

Code
summary(r)
Output
# Correlation Matrix (pearson-method)
Parameter | z | y
-----------------------
x | 0.02 | 0.01
y | 0.00 |
p-value adjustment method: Holm (1979)

---

Code
summary(r, zap_small = FALSE)
Output
# Correlation Matrix (pearson-method)
Parameter | z | y
--------------------------------
x | 0.02 | 6.02e-03
y | -3.07e-03 |
p-value adjustment method: Holm (1979)

13 changes: 13 additions & 0 deletions tests/testthat/test-correlation.R
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,16 @@ test_that("as.data.frame for correlation output", {
set.seed(123)
expect_snapshot(as.data.frame(correlation(ggplot2::msleep)))
})

test_that("correlation output with zap_small", {
set.seed(123)
d <- data.frame(
x = rnorm(10000),
y = rnorm(10000),
z = rnorm(10000)
)
r <- correlation::correlation(d)

expect_snapshot(summary(r), variant = "windows")
expect_snapshot(summary(r, zap_small = FALSE), variant = "windows")
})

0 comments on commit f11f915

Please sign in to comment.