diff --git a/.Rbuildignore b/.Rbuildignore index 9fe5249..337694f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -4,3 +4,4 @@ README.md .travis.yml .github docs +_pkgdown.yml diff --git a/DESCRIPTION b/DESCRIPTION index 2ef30b6..36a5e89 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: classInt -Version: 0.4-10 -Date: 2023-08-24 +Version: 0.4-11 +Date: 2024-11-26 Title: Choose Univariate Class Intervals Authors@R: c( person("Roger", "Bivand", role=c("aut", "cre"), email="Roger.Bivand@nhh.no", comment=c(ORCID="0000-0003-2392-6140")), diff --git a/NEWS.md b/NEWS.md index 5af3957..2dca732 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,13 @@ +## Version 0.4-11 + +- #49 permit use of `"quantile"` `style` `probs=` argument; should really use `n=`, as `probs` is set internally to `seq(0, 1, 1/n)`. For other vectors, the use of `"fixed"` `style` is preferable. + +## Version 0.4-10 + +- #46 limiting use of `nsamp=`. + +- #44 correcting logic in `largeN=` handling. + ## Version 0.4-9 - #41 issues. The maximum and minimum breaks 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. @@ -18,4 +28,4 @@ - Add `"headtails"` vignette (@dieghernan) -- Add `"headtails"` style (@dieghernan) \ No newline at end of file +- Add `"headtails"` style (@dieghernan) diff --git a/R/classInt.R b/R/classInt.R index 37ba36a..38a776e 100644 --- a/R/classInt.R +++ b/R/classInt.R @@ -107,7 +107,11 @@ classIntervals <- function(var, n, style="quantile", rtimes=3, ..., intervalClos # Fix 22: Diego Hernangómez needn <- !(style %in% c("dpih", "headtails", "box")) - if (missing(n)) n <- nclass.Sturges(var) + n_missing <- FALSE + if (missing(n)) { + n <- nclass.Sturges(var) + n_missing <- TRUE + } if (n < 2 & needn) stop("n less than 2") n <- as.integer(n) pars <- NULL @@ -187,7 +191,37 @@ classIntervals <- function(var, n, style="quantile", rtimes=3, ..., intervalClos brks <- c(pretty(x=var, n=n, ...)) } else if (style =="quantile") { # stats - brks <- c(quantile(x=var, probs=seq(0,1,1/n), ...)) + dots <- list(...) + probs <- seq(0, 1, 1/n) + if (!is.null(dots$probs)) { + if (n_missing) { + probs <- dots$probs + } else { + if (length(dots$probs)-1 != n) { + stop("both n and probs given, but length(probs)-1 != ", n) + } else probs <- dots$probs + } + r_probs <- range(probs) + if (r_probs[1] < 0 || r_probs[2] > 1) + stop("given probs range exceeds the unit interval: [", + paste(r_probs, collapse=", "), "]") + if (r_probs[1] != 0 || r_probs[2] != 1) { + warning("given probs range does not span the unit interval: [", + paste(r_probs, collapse=", "), "]") + } + if (length(unique(round(diff(probs), digits=14))) != 1L) + warning("given probs do not have equal steps") + } + na.rm <- FALSE + if (!is.null(dots$na.rm)) na.rm <- dots$na.rm + names <- FALSE + if (!is.null(dots$names)) names <- dots$names + type <- 7 + if (!is.null(dots$type)) type <- dots$type + digits <- 7 + if (!is.null(dots$digits)) digits <- dots$digits + brks <- c(quantile(x=var, probs=probs, na.rm=na.rm, names=names, + type=type, digits=digits)) names(brks) <- NULL } else if (style =="kmeans") { # stats diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000..bbe7b92 --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,3 @@ +template: + bootstrap: 5 +url: https://r-spatial.github.io/classInt/ diff --git a/docs/404.html b/docs/404.html index 7afb842..60556ed 100644 --- a/docs/404.html +++ b/docs/404.html @@ -4,112 +4,78 @@ - +