tests/testthat/test-shave.R

d <- datasets::iris[, 1:4]
d[1, 1] <- NA
d <- correlate(d)

test_that("Shave upper", {
  expect_equal(
    sum(is.na(as.matrix(shave(d, upper = TRUE)))),
    nrow(d) + sum((nrow(d) - 1):1)
  )
})

test_that("Shave lower", {
  expect_equal(
    sum(is.na(as.matrix(shave(d, upper = FALSE)))),
    nrow(d) + sum((nrow(d) - 1):1)
  )
})

test_that("Shave all", {
  expect_equal(
    sum(is.na(as.matrix(shave(shave(d, upper = TRUE), upper = FALSE)))),
    nrow(d) * nrow(d)
  )
})

Try the corrr package in your browser

Any scripts or data that you put into this service are public.

corrr documentation built on Aug. 17, 2022, 1:05 a.m.