103
103
# ' mapping = aes(x = group, y = group_mean), data = group_means_df,
104
104
# ' colour = 'red', size = 3
105
105
# ' )
106
- ggplot <- S7 :: new_generic(
107
- " ggplot2" , " data" ,
108
- fun = function (data , mapping = aes(), ... , environment = parent.frame()) {
109
- force(mapping )
110
- S7 :: S7_dispatch()
111
- }
112
- )
106
+ ggplot <- function (
107
+ data = NULL ,
108
+ mapping = aes(),
109
+ ... ,
110
+ environment = parent.frame()
111
+ ) {
112
+ UseMethod(" ggplot" )
113
+ }
114
+
115
+ # ' @export
116
+ ggplot.default <-
117
+ function (data , mapping = aes(), ... , environment = parent.frame()) {
113
118
114
- S7 :: method(ggplot , S7 :: class_any ) <- function (
115
- data , mapping = aes(), ... ,
116
- environment = parent.frame()) {
117
119
if (! missing(mapping ) && ! is_mapping(mapping )) {
118
120
cli :: cli_abort(c(
119
121
" {.arg mapping} must be created with {.fn aes}." ,
@@ -137,13 +139,11 @@ S7::method(ggplot, S7::class_any) <- function(
137
139
p
138
140
}
139
141
140
- S7 :: method(ggplot , S7 :: class_function ) <-
141
- function (data , mapping = aes(), ... ,
142
- environment = parent.frame()) {
142
+ ggplot.function <- function (data , ... ) {
143
143
# Added to avoid functions end in ggplot.default
144
144
cli :: cli_abort(c(
145
145
" {.arg data} cannot be a function." ,
146
- " i" = " Have you misspelled the {.arg data} argument in {.fn ggplot}"
146
+ " i" = " Have you misspelled the {.arg data} argument in {.fn ggplot}? "
147
147
))
148
148
}
149
149
0 commit comments