R Under development (unstable) (2023-11-28 r85645 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(cpr) > > ################################################################################ > # test that trimmed quantile warnings work > options(warn = 2) > > e <- try(trimmed_quantile(1:100, trim = 3.9, prob = 1:23 / 24, name = FALSE), silent = TRUE) > stopifnot(inherits(e, "try-error")) > stopifnot(attr(e, "condition")$message == "(converted from warning) Overruling non-integer trim with floor(trim)") > > e <- try(trimmed_quantile(1:100, trim = -3.9, prob = 1:23 / 24, name = FALSE), silent = TRUE) > stopifnot(inherits(e, "try-error")) > stopifnot(attr(e, "condition")$message == "(converted from warning) Overruling trim less than 1 with trim = 1L") > > stopifnot(isTRUE( + all.equal(suppressWarnings(trimmed_quantile(1:100, trim = 3.9, prob = 1:23 / 24, name = FALSE)) + , quantile(4:97, prob = 1:23 / 24) + , check.attributes = FALSE + ) + ) + ) > > ################################################################################ > # test that trimmed quantile results are as expected > x <- sample(runif(100, 0, 6), size = 500, replace = TRUE) > ux <- unique(x) > > xt <- x[!(x %in% range(x))] > uxt <- ux[!(ux %in% range(ux))]#-c(which.min(ux), which.max(ux))] > > stopifnot(isTRUE(all.equal(trimmed_quantile(x), quantile(uxt)))) > stopifnot(isTRUE(all.equal(trimmed_quantile(x, use_unique = FALSE), quantile(xt)))) > > ################################################################################ > ## End of File ## > ################################################################################ > > proc.time() user system elapsed 0.25 0.07 0.31