Skip to content

Commit

Permalink
Interpret NULL discrete limits as NA, fixes #2666
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Oct 16, 2019
1 parent ed739f9 commit b579b85
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/image-interact.R
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,10 @@ within_brush <- function(vals, brush, var = "x") {
# it allows you to control ordering and possible values of a discrete
# positional scale (#2410)
asNumber <- function(x, levels = NULL) {
if (length(levels)) return(match(x, levels))
if (length(levels)) {
levels <- lapply(levels, function(x) x %OR% NA)
return(match(x, levels))
}
if (is.character(x)) x <- as.factor(x)
if (is.factor(x)) x <- as.integer(x)
as.numeric(x)
Expand Down

0 comments on commit b579b85

Please sign in to comment.