mirror of
https://github.com/agdamsbo/stRoke.git
synced 2024-11-22 13:00:23 +01:00
29 lines
1.0 KiB
R
29 lines
1.0 KiB
R
test_that("quatile_cut() works for detail.list==FALSE", {
|
|
result <- quantile_cut(iris$Sepal.Length,3,detail.list=FALSE)
|
|
expect_equal(length(levels(result)), 3)
|
|
expect_s3_class(result, "factor")
|
|
})
|
|
|
|
################################################################################
|
|
|
|
test_that("quatile_cut() works for detail.list==FALSE", {
|
|
result <- quantile_cut(iris$Sepal.Length,3,detail.list=TRUE)
|
|
expect_length(result, 2)
|
|
expect_type(result, "list")
|
|
})
|
|
|
|
################################################################################
|
|
|
|
# Test created using remotes::install_github("JamesHWade/gpttools") unit test addin.
|
|
test_that("quantile_cut works correctly", {
|
|
x <- runif(100)
|
|
groups <- 5
|
|
y <- runif(100)
|
|
expect_equal(quantile_cut(x, groups, y, na.rm = TRUE),
|
|
cut(x, quantile(y, probs = seq(0, 1, 1/groups), na.rm = TRUE, names = TRUE, type = 7),
|
|
include.lowest = TRUE, labels = NULL, ordered_result = FALSE))
|
|
})
|
|
|
|
################################################################################
|
|
|