@@ -121,19 +121,18 @@ fit.model_spec <-
121121 # TODO Should probably just load the namespace
122122 load_libs(object , control $ verbosity < 2 )
123123
124- fit_func <- paste(fit_interface , object $ method $ interface , sep = " _to_" )
125-
126124 res <- switch (
127- object $ method $ interface ,
128- formula = , spark = fit_formula (
125+ fit_interface ,
126+ formula = fit_interface_formula (
129127 object = object ,
130128 formula = cl $ formula ,
131129 data = cl $ data ,
132130 control = control ,
133131 ...
134132 ),
135- recipe = fit_recipe(object , recipe , data , control = control , ... ),
136- data.frame = , matrix = fit_xy(object , x , y , control = control , ... ),
133+ matrix = fit_interface_matrix(x , y , object , control , ... ),
134+ data.frame = fit_interface_data.frame(x , y , object , control , ... ),
135+ recipe = fit_interface_recipe(recipe , data , object , control , ... ),
137136 stop(" Wrong interface type" )
138137 )
139138
@@ -456,24 +455,29 @@ check_interface <- function(formula, recipe, x, y, data, cl) {
456455 inher(formula , " formula" , cl )
457456 inher(recipe , " recipe" , cl )
458457 inher(x , c(" data.frame" , " matrix" , " tbl_spark" ), cl )
458+
459459 # `y` can be a vector (which is not a class), or a factor (which is not a vector)
460460 if (! is.null(y ) && ! is.vector(y ))
461461 inher(y , c(" data.frame" , " matrix" , " factor" , " tbl_spark" ), cl )
462462 inher(data , c(" data.frame" , " matrix" , " tbl_spark" ), cl )
463463
464- x_interface <- ! is.null(x ) & ! is.null(y )
464+ matrix_interface <- ! is.null(x ) & ! is.null(y ) && is.matrix(x )
465+ df_interface <- ! is.null(x ) & ! is.null(y ) && is.data.frame(x )
465466 rec_interface <- ! is.null(recipe ) & ! is.null(data )
466467 form_interface <- ! is.null(formula ) & ! is.null(data )
467- if (! (x_interface | rec_interface | form_interface ))
468+
469+ if (! (matrix_interface | df_interface | rec_interface | form_interface ))
468470 stop(" Incomplete specification of arguments; used either 'x/y', " ,
469471 " 'formula/data', or 'recipe/data' combinations." , call. = FALSE )
470- if (sum(c(x_interface , rec_interface , form_interface )) > 1 )
472+ if (sum(c(matrix_interface , df_interface , rec_interface , form_interface )) > 1 )
471473 stop(" Too many specifications of arguments; used either 'x/y', " ,
472474 " 'formula/data', or 'recipe/data' combinations." , call. = FALSE )
473- if (x_interface ) return (" xy" )
475+
476+ if (matrix_interface ) return (" data.frame" )
477+ if (df_interface ) return (" data.frame" )
474478 if (rec_interface ) return (" recipe" )
475479 if (form_interface ) return (" formula" )
476- stop(" Error in checking the interface" )
480+ stop(" Error when checking the interface" )
477481}
478482
479483
0 commit comments