Skip to content

Commit

Permalink
Merge pull request #50 from r-spatial/q_probs
Browse files Browse the repository at this point in the history
Q probs
  • Loading branch information
rsbivand authored Nov 28, 2024
2 parents 240703c + 5ba8dc4 commit 6487677
Show file tree
Hide file tree
Showing 117 changed files with 22,445 additions and 2,203 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ README.md
.travis.yml
.github
docs
_pkgdown.yml
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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="[email protected]", comment=c(ORCID="0000-0003-2392-6140")),
Expand Down
12 changes: 11 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -18,4 +28,4 @@

- Add `"headtails"` vignette (@dieghernan)

- Add `"headtails"` style (@dieghernan)
- Add `"headtails"` style (@dieghernan)
38 changes: 36 additions & 2 deletions R/classInt.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
template:
bootstrap: 5
url: https://r-spatial.github.io/classInt/
126 changes: 46 additions & 80 deletions docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6487677

Please sign in to comment.