tests/testthat/test-contrank.R

test_that("contrank", {
  expectrank <- function(x) {
    r <- rank(x, ties.method = "average")
    cr <- contrank(x)
    expect_equal(all(r-1 <= cr & cr <= r), TRUE)
  }
  expectrank(c(1,2,2))
  expectrank(c(2,2,3))
  for(n in c(1,2,3,4,5,6,10, 100)) {
    expectrank(rnorm(n))
    expectrank(sample(1:3, n, replace=TRUE))
  }
})

Try the GET package in your browser

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

GET documentation built on May 29, 2024, 9:23 a.m.