Skip to content

Commit 28e92f0

Browse files
committed
test non-negative iqr_mult
1 parent d6b3453 commit 28e92f0

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

R/classInt.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ classIntervals <- function(var, n, style="quantile", rtimes=3, ..., intervalClos
357357

358358
dots <- list(...)
359359
iqr_mult <- ifelse(is.null(dots$iqr_mult), 1.5, dots$iqr_mult)
360+
stopifnot(iqr_mult >= 0)
360361
qtype <- ifelse(is.null(dots$type), 7, dots$type)
361362
legacy <- ifelse(is.null(dots$legacy), FALSE, dots$legacy)
362363

inst/tinytest/test_box.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ set.seed(101)
33
x <- rnorm(50)
44
expect_error(print(classIntervals(x, style="box", iqr_mult=1.5, type=5, legacy=TRUE)))
55
expect_inherits(classIntervals(x, style="box", iqr_mult=1.5, type=5), "classIntervals")
6-
6+
expect_error(classIntervals(x, style="box", iqr_mult=-1))

man/classIntervals.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ classIntervals2shingle(x)
7070
7171
The "maximum" style uses the Maximum Breaks method of classification finding the k - 1 largest differences in \code{var}. The mean of the values that generated the largest splits is used as the interval boundary.
7272
73-
The "box" style generates 7 breaks (therefore 6 categories) based on a box-and-whisker plot. First and last categories include the data values considered as outliers, and the four remaining categories are defined by the percentiles 25, 50 and 75 of the data distribution. By default, the identification of outliers is based on the interquantile range (IQR), so values lower than percentile 25 - 1.5 * IQR or higher than percentile 75 + 1.5 * IQR are considered as outliers. The multiplier applied to the IQR \code{iqr_mult = 1.5} may be modified through \code{\dots}. As in the \code{"quantile"} style, the \code{type=} argument may be used to choose the quantile algoritm (default 7, standard boxplots use 5 or 2). From 0.4-9 and #41, the maximum and minimum are set to \code{+Inf} and \code{-Inf} to avoid errors induced in the earlier version where breaks could cease to be strictly ascending. The \code{legacy=} argument with value \code{TRUE} may be used to revert to the previous behaviour.
73+
The "box" style generates 7 breaks (therefore 6 categories) based on a box-and-whisker plot. First and last categories include the data values considered as outliers, and the four remaining categories are defined by the percentiles 25, 50 and 75 of the data distribution. By default, the identification of outliers is based on the interquantile range (IQR), so values lower than percentile 25 - 1.5 * IQR or higher than percentile 75 + 1.5 * IQR are considered as outliers. The multiplier applied to the IQR \code{iqr_mult = 1.5} may be modified through \code{\dots}; the value must not be negative. As in the \code{"quantile"} style, the \code{type=} argument may be used to choose the quantile algoritm (default 7, standard boxplots use 5 or 2). From 0.4-9 and #41, the maximum and minimum are set to \code{+Inf} and \code{-Inf} to avoid errors induced in the earlier version where breaks could cease to be strictly ascending. The \code{legacy=} argument with value \code{TRUE} may be used to revert to the previous behaviour.
7474
7575
}
7676

0 commit comments

Comments
 (0)