test_that("default vec_rescale returns the same as scales::rescale", {
test <- c(1.1, NA, Inf, 10)
expect_identical(vec_rescale(test), scales::rescale(test))
expect_identical(vec_rescale(test, to = c(0, 2)),
scales::rescale(test, to = c(0, 2)))
expect_identical(vec_rescale(test, from = c(-10, 20)),
scales::rescale(test, from = c(-10, 20)))
})
test_that("default vec_force_flatten works", {
# limits match input
expect_equal(vec_force_flat(1:10, c(1, 10)),
seq(0, 1, length.out = 10))
# limits is larger than input
expect_equal(vec_force_flat(1:11, c(1, 21)),
seq(0, 0.5, length.out = 11))
# input is larger than limits
expect_equal(vec_force_flat(1:10, c(1, 5.5)),
seq(0, 2, length.out = 10))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.