Skip to content

Commit ed72eef

Browse files
authored
Merge pull request #45 from r-spatial/LargeN
address #44
2 parents 7949100 + f7b2e03 commit ed72eef

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

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-9
3-
Date: 2023-02-21
2+
Version: 0.4-10
3+
Date: 2023-08-24
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")),

R/classInt.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,13 @@ classIntervals <- function(var, n, style="quantile", rtimes=3, ..., intervalClos
132132
# introduced related to https://github.com/r-spatial/classInt/issues/7
133133
sampling <- FALSE
134134
if (warnLargeN &&
135-
(style %in% c("kmeans", "hclust", "bclust", "fisher", "jenks"))) {
135+
(style %in% c("fisher", "jenks"))) {
136136
if (nobs > largeN) {
137137
warning("N is large, and some styles will run very slowly; sampling imposed")
138138
sampling <- TRUE
139-
nsamp <- ifelse(samp_prop*nobs > 3000, as.integer(ceiling(samp_prop*nobs)), 3000L)
139+
# issue 44
140+
nsamp <- as.integer(ceiling(samp_prop*nobs))
141+
if (nsamp > largeN) nsamp <- as.integer(largeN)
140142
}
141143
}
142144
if (style =="fixed") {

inst/tinytest/test_largeN.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
library(classInt)
2+
# issue 44
3+
set.seed(101)
4+
large_n <- 1000
5+
x <- 1:(large_n + 1)
6+
expect_warning(classInt::classIntervals(x, n = 10, style = "fisher",
7+
largeN = large_n, samp_prop = 0.05))
8+

man/classIntervals.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ classIntervals2shingle(x)
3030
\item{dataPrecision}{default NULL, permits rounding of the interval endpoints (added by Richard Dunlap). The data precision used for printing interval values in the legend returned by \code{findColours}, and in the \code{print} method for classIntervals objects. If intervalClosure is \dQuote{left}, the value returned is \code{ceiling} of the data value multiplied by 10 to the dataPrecision power, divided by 10 to the dataPrecision power. The argument does not round \code{var}, the input variable.}
3131
\item{warnSmallN}{default TRUE, if FALSE, quietens warning for n >= nobs}
3232
\item{warnLargeN}{default TRUE, if FALSE large data handling not used}
33-
\item{largeN}{default 3000L, the QGIS sampling threshold; over 3000, the observations presented to "fisher" and "jenks" are either a \code{samp_prop=} sample or a sample of 3000, whichever is larger}
33+
\item{largeN}{default 3000L, the QGIS sampling threshold; over \code{largeN}, the observations presented to "fisher" and "jenks" are either a \code{samp_prop=} sample or a sample of \code{largeN}, whichever is smaller}
3434
\item{samp_prop}{default 0.1, QGIS 10\% sampling proportion}
3535
\item{gr}{default \code{c("[", "]")}, if the \pkg{units} package is available, \code{units::units_options("group")} may be used directly to give the enclosing bracket style}
3636
\item{\dots}{arguments to be passed to the functions called in each style}

0 commit comments

Comments
 (0)