@@ -94,7 +94,9 @@ getBins <- function(domain, x, bins, pretty) {
9494}
9595
9696# ' @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}.
98100# ' @param bins Either a numeric vector of two or more unique cut points or a
99101# ' single number (greater than or equal to 2) giving the number of intervals
100102# ' into which the domain values are to be cut.
@@ -103,10 +105,11 @@ getBins <- function(domain, x, bins, pretty) {
103105# ' \code{pretty = TRUE}, the actual number of bins may not be the number of
104106# ' bins you specified. When \code{pretty = FALSE}, \code{\link{seq}()} is used
105107# ' to generate the bins and the breaks may not be "pretty".
108+ # ' @param right parameter supplied to cut. See Details
106109# ' @rdname colorNumeric
107110# ' @export
108111colorBin <- 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 ) {
110113
111114 # domain usually needs to be explicitly provided (even if NULL) but not if
112115 # breaks are specified
@@ -126,7 +129,7 @@ colorBin <- function(palette, domain, bins = 7, pretty = TRUE,
126129 return (pf(x ))
127130 }
128131 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 )
130133 if (any(is.na(x ) != is.na(ints )))
131134 warning(" Some values were outside the color scale and will be treated as NA" )
132135 colorFunc(ints )
@@ -143,7 +146,7 @@ colorBin <- function(palette, domain, bins = 7, pretty = TRUE,
143146# ' @export
144147colorQuantile <- function (palette , domain , n = 4 ,
145148 probs = seq(0 , 1 , length.out = n + 1 ), na.color = " #808080" , alpha = FALSE ,
146- reverse = FALSE ) {
149+ reverse = FALSE , right = FALSE ) {
147150
148151 if (! is.null(domain )) {
149152 bins <- quantile(domain , probs , na.rm = TRUE , names = FALSE )
@@ -162,7 +165,7 @@ colorQuantile <- function(palette, domain, n = 4,
162165
163166 withColorAttr(" quantile" , list (probs = probs , na.color = na.color ), function (x ) {
164167 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 )
166169 if (any(is.na(x ) != is.na(ints )))
167170 warning(" Some values were outside the color scale and will be treated as NA" )
168171 colorFunc(ints )
0 commit comments