Skip to content

Commit 6487677

Browse files
authored
Merge pull request #50 from r-spatial/q_probs
Q probs
2 parents 240703c + 5ba8dc4 commit 6487677

File tree

117 files changed

+22445
-2203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+22445
-2203
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ README.md
44
.travis.yml
55
.github
66
docs
7+
_pkgdown.yml

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: classInt
2-
Version: 0.4-10
3-
Date: 2023-08-24
2+
Version: 0.4-11
3+
Date: 2024-11-26
44
Title: Choose Univariate Class Intervals
55
Authors@R: c(
66
person("Roger", "Bivand", role=c("aut", "cre"), email="[email protected]", comment=c(ORCID="0000-0003-2392-6140")),

NEWS.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## Version 0.4-11
2+
3+
- #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.
4+
5+
## Version 0.4-10
6+
7+
- #46 limiting use of `nsamp=`.
8+
9+
- #44 correcting logic in `largeN=` handling.
10+
111
## Version 0.4-9
212

313
- #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 @@
1828

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

21-
- Add `"headtails"` style (@dieghernan)
31+
- Add `"headtails"` style (@dieghernan)

R/classInt.R

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ classIntervals <- function(var, n, style="quantile", rtimes=3, ..., intervalClos
107107
# Fix 22: Diego Hernangómez
108108
needn <- !(style %in% c("dpih", "headtails", "box"))
109109

110-
if (missing(n)) n <- nclass.Sturges(var)
110+
n_missing <- FALSE
111+
if (missing(n)) {
112+
n <- nclass.Sturges(var)
113+
n_missing <- TRUE
114+
}
111115
if (n < 2 & needn) stop("n less than 2")
112116
n <- as.integer(n)
113117
pars <- NULL
@@ -187,7 +191,37 @@ classIntervals <- function(var, n, style="quantile", rtimes=3, ..., intervalClos
187191
brks <- c(pretty(x=var, n=n, ...))
188192
} else if (style =="quantile") {
189193
# stats
190-
brks <- c(quantile(x=var, probs=seq(0,1,1/n), ...))
194+
dots <- list(...)
195+
probs <- seq(0, 1, 1/n)
196+
if (!is.null(dots$probs)) {
197+
if (n_missing) {
198+
probs <- dots$probs
199+
} else {
200+
if (length(dots$probs)-1 != n) {
201+
stop("both n and probs given, but length(probs)-1 != ", n)
202+
} else probs <- dots$probs
203+
}
204+
r_probs <- range(probs)
205+
if (r_probs[1] < 0 || r_probs[2] > 1)
206+
stop("given probs range exceeds the unit interval: [",
207+
paste(r_probs, collapse=", "), "]")
208+
if (r_probs[1] != 0 || r_probs[2] != 1) {
209+
warning("given probs range does not span the unit interval: [",
210+
paste(r_probs, collapse=", "), "]")
211+
}
212+
if (length(unique(round(diff(probs), digits=14))) != 1L)
213+
warning("given probs do not have equal steps")
214+
}
215+
na.rm <- FALSE
216+
if (!is.null(dots$na.rm)) na.rm <- dots$na.rm
217+
names <- FALSE
218+
if (!is.null(dots$names)) names <- dots$names
219+
type <- 7
220+
if (!is.null(dots$type)) type <- dots$type
221+
digits <- 7
222+
if (!is.null(dots$digits)) digits <- dots$digits
223+
brks <- c(quantile(x=var, probs=probs, na.rm=na.rm, names=names,
224+
type=type, digits=digits))
191225
names(brks) <- NULL
192226
} else if (style =="kmeans") {
193227
# stats

_pkgdown.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
template:
2+
bootstrap: 5
3+
url: https://r-spatial.github.io/classInt/

docs/404.html

Lines changed: 46 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)