From 499d496cd086c7d614ac9a62ef6e669479bd6c24 Mon Sep 17 00:00:00 2001 From: Bo Gao Date: Wed, 11 May 2022 15:53:13 +0100 Subject: [PATCH] `ordered = TRUE` for `colorFactor` When the code is written as `pal <- colorFactor(c("navy", "red"), domain = c("ship", "pirate"))`, then it is highly likely that the user's intention is to have `navy` for `ship`, and `red` for `pirate`. Therefore it makes more sense that `colorFactor` should assume that the `domain` vector is already ordered (`ordered = TRUE`) unless stated otherwise. --- R/colors.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/colors.R b/R/colors.R index 5a816b5b9..96ccdc730 100644 --- a/R/colors.R +++ b/R/colors.R @@ -208,7 +208,7 @@ getLevels <- function(domain, x, lvls, ordered) { #' factor, treat it as already in the correct order #' @rdname colorNumeric #' @export -colorFactor <- function(palette, domain, levels = NULL, ordered = FALSE, +colorFactor <- function(palette, domain, levels = NULL, ordered = TRUE, na.color = "#808080", alpha = FALSE, reverse = FALSE) { # domain usually needs to be explicitly provided (even if NULL) but not if