Skip to content

Commit

Permalink
Merge pull request #45 from r-spatial/LargeN
Browse files Browse the repository at this point in the history
address #44
  • Loading branch information
rsbivand authored Aug 29, 2023
2 parents 7949100 + f7b2e03 commit ed72eef
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
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-9
Date: 2023-02-21
Version: 0.4-10
Date: 2023-08-24
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
6 changes: 4 additions & 2 deletions R/classInt.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,13 @@ classIntervals <- function(var, n, style="quantile", rtimes=3, ..., intervalClos
# introduced related to https://github.com/r-spatial/classInt/issues/7
sampling <- FALSE
if (warnLargeN &&
(style %in% c("kmeans", "hclust", "bclust", "fisher", "jenks"))) {
(style %in% c("fisher", "jenks"))) {
if (nobs > largeN) {
warning("N is large, and some styles will run very slowly; sampling imposed")
sampling <- TRUE
nsamp <- ifelse(samp_prop*nobs > 3000, as.integer(ceiling(samp_prop*nobs)), 3000L)
# issue 44
nsamp <- as.integer(ceiling(samp_prop*nobs))
if (nsamp > largeN) nsamp <- as.integer(largeN)
}
}
if (style =="fixed") {
Expand Down
8 changes: 8 additions & 0 deletions inst/tinytest/test_largeN.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
library(classInt)
# issue 44
set.seed(101)
large_n <- 1000
x <- 1:(large_n + 1)
expect_warning(classInt::classIntervals(x, n = 10, style = "fisher",
largeN = large_n, samp_prop = 0.05))

2 changes: 1 addition & 1 deletion man/classIntervals.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ classIntervals2shingle(x)
\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.}
\item{warnSmallN}{default TRUE, if FALSE, quietens warning for n >= nobs}
\item{warnLargeN}{default TRUE, if FALSE large data handling not used}
\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}
\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}
\item{samp_prop}{default 0.1, QGIS 10\% sampling proportion}
\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}
\item{\dots}{arguments to be passed to the functions called in each style}
Expand Down

0 comments on commit ed72eef

Please sign in to comment.