@@ -94,7 +94,9 @@ getBins <- function(domain, x, bins, pretty) {
94
94
}
95
95
96
96
# ' @details \code{colorBin} also maps continuous numeric data, but performs
97
- # ' binning based on value (see the \code{\link[base]{cut}} function).
97
+ # ' binning based on value (see the \code{\link[base]{cut}} function). \code{colorBin}
98
+ # ' defaults for the \code{\link[base]{cut}} function are \code{include.lowest
99
+ # ' = TRUE} and \code{right = FALSE}.
98
100
# ' @param bins Either a numeric vector of two or more unique cut points or a
99
101
# ' single number (greater than or equal to 2) giving the number of intervals
100
102
# ' into which the domain values are to be cut.
@@ -103,10 +105,11 @@ getBins <- function(domain, x, bins, pretty) {
103
105
# ' \code{pretty = TRUE}, the actual number of bins may not be the number of
104
106
# ' bins you specified. When \code{pretty = FALSE}, \code{\link{seq}()} is used
105
107
# ' to generate the bins and the breaks may not be "pretty".
108
+ # ' @param right parameter supplied to cut. See Details
106
109
# ' @rdname colorNumeric
107
110
# ' @export
108
111
colorBin <- function (palette , domain , bins = 7 , pretty = TRUE ,
109
- na.color = " #808080" , alpha = FALSE , reverse = FALSE ) {
112
+ na.color = " #808080" , alpha = FALSE , reverse = FALSE , right = FALSE ) {
110
113
111
114
# domain usually needs to be explicitly provided (even if NULL) but not if
112
115
# breaks are specified
@@ -126,7 +129,7 @@ colorBin <- function(palette, domain, bins = 7, pretty = TRUE,
126
129
return (pf(x ))
127
130
}
128
131
binsToUse <- getBins(domain , x , bins , pretty )
129
- ints <- cut(x , binsToUse , labels = FALSE , include.lowest = TRUE , right = FALSE )
132
+ ints <- cut(x , binsToUse , labels = FALSE , include.lowest = TRUE , right = right )
130
133
if (any(is.na(x ) != is.na(ints )))
131
134
warning(" Some values were outside the color scale and will be treated as NA" )
132
135
colorFunc(ints )
@@ -143,7 +146,7 @@ colorBin <- function(palette, domain, bins = 7, pretty = TRUE,
143
146
# ' @export
144
147
colorQuantile <- function (palette , domain , n = 4 ,
145
148
probs = seq(0 , 1 , length.out = n + 1 ), na.color = " #808080" , alpha = FALSE ,
146
- reverse = FALSE ) {
149
+ reverse = FALSE , right = FALSE ) {
147
150
148
151
if (! is.null(domain )) {
149
152
bins <- quantile(domain , probs , na.rm = TRUE , names = FALSE )
@@ -162,7 +165,7 @@ colorQuantile <- function(palette, domain, n = 4,
162
165
163
166
withColorAttr(" quantile" , list (probs = probs , na.color = na.color ), function (x ) {
164
167
binsToUse <- quantile(x , probs , na.rm = TRUE , names = FALSE )
165
- ints <- cut(x , binsToUse , labels = FALSE , include.lowest = TRUE , right = FALSE )
168
+ ints <- cut(x , binsToUse , labels = FALSE , include.lowest = TRUE , right = right )
166
169
if (any(is.na(x ) != is.na(ints )))
167
170
warning(" Some values were outside the color scale and will be treated as NA" )
168
171
colorFunc(ints )
0 commit comments