R Under development (unstable) (2024-01-14 r85805 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(DescTools) > > # stopifnot(exprs = { > # all.equal(pretty10exp(10^expo, drop.1=TRUE, sub10 = c(-2, 2)), > # expression(10^-3, 0.01, 0.1, 1, 10, 100, 10^3, 10^4)) > # > # identical(pretty10exp(10^expo, drop.1=TRUE, sub10 = c(-2, 2), lab.type="latex"), > # c("$10^{-3}$", "0.01", "0.1", "1", "10", "100", > # "$10^{3}$", "$10^{4}$")) > # ## gave exponential format for "latex" case. > # }) > # > > set.seed(45) > (z <- as.numeric(names(w <- table(x <- sample(-10:20, size=50, r=TRUE))))) [1] -9 -8 -7 -6 -5 -4 -3 -2 0 3 4 5 6 7 8 9 10 12 13 15 16 17 18 19 20 > > stopifnot(all( + identical(Mode(5), structure(NA_real_, freq = NA_integer_)) + , identical(Mode(NA), structure(NA_real_, freq = NA_integer_)) + , identical(Mode(c(NA, NA)), structure(NA_real_, freq = NA_integer_)) + , identical(Mode(c(NA, 0:5)), structure(NA_real_, freq = NA_integer_)) + , identical(Mode(c(NA, 0:5), na.rm=TRUE), structure(NA_real_, freq = NA_integer_)) + , identical(Mode(c(NA, 0:5, 5), na.rm=TRUE), structure(5, freq = 2L)) + , identical(Mode(c(0:5, 4, 5, 6)), structure(c(4, 5), freq = 2L)) + , identical(Mode(c(0:8, rep(c(1,3, 8), each=5))), structure(c(1, 3, 8), freq = 6L)) + + , all.equal(Kurt(x = z, weights = w, method = 1), Kurt(x = x, method = 1)) + , all.equal(Kurt(x = z, weights = w, method = 2), Kurt(x = x, method = 2)) + , all.equal(Kurt(x = z, weights = w, method = 3), Kurt(x = x, method = 3)) + + , all.equal(Skew(x = z, weights = w, method = 1), Skew(x = x, method = 1)) + , all.equal(Skew(x = z, weights = w, method = 2), Skew(x = x, method = 2)) + , all.equal(Skew(x = z, weights = w, method = 3), Skew(x = x, method = 3)) + + , all.equal(CoefVar(z, weights = w, unbiased = TRUE), CoefVar(x, unbiased = TRUE)) + , all.equal(CoefVar(z, weights = w, unbiased = FALSE), CoefVar(x, unbiased = FALSE)) + + , all.equal(MeanAD(x), MeanAD(z, w)) + , all.equal(MeanAD(x, center = Median), MeanAD(z, w, center = Median)) + , all.equal(MeanAD(x, center = 7), MeanAD(z, w, center = 7)) + + )) > > > > # test Desc base function > > x <- c(rnorm(n = 100, sd = 10), NA) > z <- Desc(x)[[1]] > > stopifnot(all( + identical(z$length, length(x)) + , identical(z$NAs, sum(is.na(x))) + , identical(z$unique, length(unique(na.omit(x)))) + , identical(z$`0s`, sum(x==0, na.rm=TRUE)) + , IsZero(z$mean - mean(x, na.rm=TRUE)) + , identical(unname(z$quant), + unname(quantile(x, na.rm=TRUE, probs=c(0,0.05,.1,.25,.5,.75,.9,.95,1)))) + , identical(z$range, diff(range(x, na.rm=TRUE))) + , IsZero(z$sd - sd(x, na.rm=TRUE)) + , IsZero(z$vcoef - sd(x, na.rm=TRUE)/mean(x, na.rm = TRUE)) + , identical(z$mad, mad(x, na.rm=TRUE)) + , identical(z$IQR, IQR(x, na.rm=TRUE)) + )) Error: all(identical(z$length, length(x)), identical(z$NAs, sum(is.na(x))), .... is not TRUE Execution halted