R Under development (unstable) (2024-02-14 r85901 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 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) > > # testing of the iknots_or_df method > > ################################################################################ > # check that the method is not exported > stopifnot(!grepl("iknots_or_df", ls("package:cpr"))) > cpr_namespace <- ls( getNamespace("cpr"), all.names = TRUE) > stopifnot(sum(cpr_namespace == "iknots_or_df") == 1L) > stopifnot(sum(grepl("^coef_vcov$", cpr_namespace)) == 1L) > > ################################################################################ > # use iknots over all else > xvec <- runif(600, min = 0, max = 3) > stopifnot(identical( + cpr:::iknots_or_df(x = xvec, iknots = 1:2, df = NULL, order = NULL) + , + 1:2 + )) > > # a warning when iknots and df are provided > awarning <- tryCatch( + cpr:::iknots_or_df(x = xvec, iknots = 1:2, df = 56, order = 12) + , warning = function(w) w) > stopifnot(inherits(awarning, "warning")) > stopifnot(identical(awarning$message, "Both iknots and df defined, using iknots")) > > # rtn numeric(0) when df == order > for (i in 2:10) { + stopifnot(identical(cpr:::iknots_or_df(x = xvec, iknots = NULL, df = i, order = i), + numeric(0))) + } > > # trimmed_quantile when df > order > for (i in 2:10) { + stopifnot( + isTRUE( + all.equal( + cpr:::iknots_or_df(x = xvec, iknots = NULL, df = 4 + i, order = 4) + , + trimmed_quantile(x = xvec, probs = seq(1, i, by = 1) / (i + 1)) + ) + ) + ) + } > > > ################################################################################ > # End of File # > ################################################################################ > > proc.time() user system elapsed 0.32 0.01 0.34