@@ -684,19 +684,7 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
684
684
if (length(x ) == 0 ) {
685
685
return ()
686
686
}
687
- # Intercept error here to give examples and mention scale in call
688
- if (is.factor(x ) || ! typeof(x ) %in% c(" integer" , " double" )) {
689
- # These assumptions only hold for standard ContinuousRange class, so
690
- # we skip the error if another range class is used
691
- if (inherits(self $ range , " ContinuousRange" )) {
692
- cli :: cli_abort(
693
- c(" Discrete values supplied to continuous scale." ,
694
- i = " Example values: {.and {.val {head(x, 5)}}}" ),
695
- call = self $ call
696
- )
697
- }
698
- }
699
- self $ range $ train(x )
687
+ self $ range $ train(x , call = self $ call )
700
688
},
701
689
702
690
is_empty = function (self ) {
@@ -964,19 +952,12 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale,
964
952
if (length(x ) == 0 ) {
965
953
return ()
966
954
}
967
- # Intercept error here to give examples and mention scale in call
968
- if (! is.discrete(x )) {
969
- # These assumptions only hold for standard DiscreteRange class, so
970
- # we skip the error if another range class is used
971
- if (inherits(self $ range , " DiscreteRange" )) {
972
- cli :: cli_abort(
973
- c(" Continuous values supplied to discrete scale." ,
974
- i = " Example values: {.and {.val {head(x, 5)}}}" ),
975
- call = self $ call
976
- )
977
- }
978
- }
979
- self $ range $ train(x , drop = self $ drop , na.rm = ! self $ na.translate )
955
+ self $ range $ train(
956
+ x ,
957
+ drop = self $ drop ,
958
+ na.rm = ! self $ na.translate ,
959
+ call = self $ call
960
+ )
980
961
},
981
962
982
963
transform = identity ,
@@ -1196,17 +1177,16 @@ ScaleBinned <- ggproto("ScaleBinned", Scale,
1196
1177
is_discrete = function () FALSE ,
1197
1178
1198
1179
train = function (self , x ) {
1180
+ if (length(x ) == 0 ) {
1181
+ return ()
1182
+ }
1199
1183
if (! is.numeric(x )) {
1200
1184
cli :: cli_abort(
1201
1185
" Binned scales only support continuous data." ,
1202
1186
call = self $ call
1203
1187
)
1204
1188
}
1205
-
1206
- if (length(x ) == 0 ) {
1207
- return ()
1208
- }
1209
- self $ range $ train(x )
1189
+ self $ range $ train(x , call = self $ call )
1210
1190
},
1211
1191
1212
1192
transform = default_transform ,
0 commit comments