Skip to content

Commit 6741938

Browse files
authored
Tiptoe around na.value (#6500)
* separate logic for complex structures * use `is_null`
1 parent d57ce4c commit 6741938

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

R/scale-.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,11 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale,
13151315
if (!is_null(pal_names)) {
13161316
# if pal is named, limit the pal by the names first,
13171317
# then limit the values by the pal
1318-
vec_slice(pal, is.na(match(pal_names, limits))) <- na_value
1318+
if (is_null(dim(pal))) {
1319+
pal[is.na(match(pal_names, limits))] <- na_value
1320+
} else {
1321+
vec_slice(pal, is.na(match(pal_names, limits))) <- na_value
1322+
}
13191323
pal <- vec_set_names(pal, NULL)
13201324
limits <- pal_names
13211325
}

0 commit comments

Comments
 (0)