extract classes from classInterval object
findCols.Rd
This helper function is a wrapper for findInterval
to extract classes from a "classInterval" object
Examples
xvar <- c(22361, 9573, 4836, 5309, 10384, 4359, 11016, 4414, 3327, 3408,
17816, 6909, 6936, 7990, 3758, 3569, 21965, 3605, 2181, 1892,
2459, 2934, 6399, 8578, 8537, 4840, 12132, 3734, 4372, 9073,
7508, 5203)
findCols(classIntervals(xvar, 5, "sd"), factor = FALSE)
#> [1] 5 3 2 2 3 2 3 2 2 2 5 2 2 3 2 2 5 2 2 1 2 2 2 3 3 2 3 2 2 3 3 2
findCols(classIntervals(xvar, 5, "sd"), factor = TRUE)
#> [1] [17640.44,22845.39] [7230.531,12435.48) [2025.578,7230.531)
#> [4] [2025.578,7230.531) [7230.531,12435.48) [2025.578,7230.531)
#> [7] [7230.531,12435.48) [2025.578,7230.531) [2025.578,7230.531)
#> [10] [2025.578,7230.531) [17640.44,22845.39] [2025.578,7230.531)
#> [13] [2025.578,7230.531) [7230.531,12435.48) [2025.578,7230.531)
#> [16] [2025.578,7230.531) [17640.44,22845.39] [2025.578,7230.531)
#> [19] [2025.578,7230.531) [-3179.375,2025.578) [2025.578,7230.531)
#> [22] [2025.578,7230.531) [2025.578,7230.531) [7230.531,12435.48)
#> [25] [7230.531,12435.48) [2025.578,7230.531) [7230.531,12435.48)
#> [28] [2025.578,7230.531) [2025.578,7230.531) [7230.531,12435.48)
#> [31] [7230.531,12435.48) [2025.578,7230.531)
#> 5 Levels: [-3179.375,2025.578) [2025.578,7230.531) ... [17640.44,22845.39]
if (!require("spData", quietly=TRUE)) {
message("spData package needed for examples")
run <- FALSE
} else {
run <- TRUE
}
if (run) {
data(jenks71, package="spData")
fix5 <- classIntervals(jenks71$jenks71, n=5, style="fixed",
fixedBreaks=c(15.57, 25, 50, 75, 100, 155.30))
print(fix5)
}
#> style: fixed
#> one of 3,921,225 possible partitions of this variable into 5 classes
#> [15.57,25) [25,50) [50,75) [75,100) [100,155.3]
#> 6 34 42 14 6
if (run) {
print(findCols(fix5))
print(findCols(fix5, factor = TRUE))
}
#> [1] 3 4 4 3 4 4 4 4 5 5 5 5 4 4 3 4 4 4 4 5 3 4 3 3 4 3 3 3 3 5 3 3 3 3 3 3 3
#> [38] 3 3 3 2 3 3 2 3 3 2 3 3 2 3 3 3 3 3 3 3 3 2 3 2 3 3 3 2 2 3 3 2 2 2 2 2 3
#> [75] 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 1 1 2 1 1 1 2 2
#> [1] [50,75) [75,100) [75,100) [50,75) [75,100) [75,100)
#> [7] [75,100) [75,100) [100,155.3] [100,155.3] [100,155.3] [100,155.3]
#> [13] [75,100) [75,100) [50,75) [75,100) [75,100) [75,100)
#> [19] [75,100) [100,155.3] [50,75) [75,100) [50,75) [50,75)
#> [25] [75,100) [50,75) [50,75) [50,75) [50,75) [100,155.3]
#> [31] [50,75) [50,75) [50,75) [50,75) [50,75) [50,75)
#> [37] [50,75) [50,75) [50,75) [50,75) [25,50) [50,75)
#> [43] [50,75) [25,50) [50,75) [50,75) [25,50) [50,75)
#> [49] [50,75) [25,50) [50,75) [50,75) [50,75) [50,75)
#> [55] [50,75) [50,75) [50,75) [50,75) [25,50) [50,75)
#> [61] [25,50) [50,75) [50,75) [50,75) [25,50) [25,50)
#> [67] [50,75) [50,75) [25,50) [25,50) [25,50) [25,50)
#> [73] [25,50) [50,75) [25,50) [25,50) [25,50) [25,50)
#> [79] [50,75) [25,50) [25,50) [25,50) [25,50) [25,50)
#> [85] [25,50) [25,50) [25,50) [25,50) [25,50) [15.57,25)
#> [91] [25,50) [25,50) [25,50) [25,50) [15.57,25) [15.57,25)
#> [97] [25,50) [15.57,25) [15.57,25) [15.57,25) [25,50) [25,50)
#> Levels: [15.57,25) [25,50) [50,75) [75,100) [100,155.3]