@@ -635,11 +635,15 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
635
635
}
636
636
# Intercept error here to give examples and mention scale in call
637
637
if (is.factor(x ) || ! typeof(x ) %in% c(" integer" , " double" )) {
638
- cli :: cli_abort(
639
- c(" Discrete values supplied to continuous scale." ,
640
- i = " Example values: {.and {.val {head(x, 5)}}}" ),
641
- call = self $ call
642
- )
638
+ # These assumptions only hold for standard ContinuousRange class, so
639
+ # we skip the error if another range class is used
640
+ if (inherits(self $ range , " ContinuousRange" )) {
641
+ cli :: cli_abort(
642
+ c(" Discrete values supplied to continuous scale." ,
643
+ i = " Example values: {.and {.val {head(x, 5)}}}" ),
644
+ call = self $ call
645
+ )
646
+ }
643
647
}
644
648
self $ range $ train(x )
645
649
},
@@ -909,11 +913,15 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale,
909
913
}
910
914
# Intercept error here to give examples and mention scale in call
911
915
if (! is.discrete(x )) {
912
- cli :: cli_abort(
913
- c(" Continuous values supplied to discrete scale." ,
914
- i = " Example values: {.and {.val {head(x, 5)}}}" ),
915
- call = self $ call
916
- )
916
+ # These assumptions only hold for standard DiscreteRange class, so
917
+ # we skip the error if another range class is used
918
+ if (inherits(self $ range , " DiscreteRange" )) {
919
+ cli :: cli_abort(
920
+ c(" Continuous values supplied to discrete scale." ,
921
+ i = " Example values: {.and {.val {head(x, 5)}}}" ),
922
+ call = self $ call
923
+ )
924
+ }
917
925
}
918
926
self $ range $ train(x , drop = self $ drop , na.rm = ! self $ na.translate )
919
927
},
0 commit comments