@@ -15,12 +15,8 @@ form_form <-
1515
1616 object <- check_mode(object , y_levels )
1717
18- # check to see of there are any `expr` in the arguments then
19- # run a function that evaluates the data and subs in the
20- # values of the expressions. we would have to evaluate the
21- # formula (perhaps with and without dummy variables) to get
22- # the appropraite number of columns. (`..vars..` vs `..cols..`)
23- # Perhaps use `convert_form_to_xy_fit` here to get the results.
18+ # embed descriptor functions in the quosure environments
19+ # for each of the args provided
2420
2521 if (make_descr(object )) {
2622 data_stats <- get_descr_form(env $ formula , env $ data )
@@ -83,6 +79,24 @@ xy_xy <- function(object, env, control, target = "none", ...) {
8379
8480 object <- check_mode(object , levels(env $ y ))
8581
82+ if (make_descr(object )) {
83+ data_stats <- get_descr_xy(env $ x , env $ y )
84+
85+ object $ args <- purrr :: map(object $ args , ~ {
86+
87+ .x_env <- rlang :: quo_get_env(.x )
88+
89+ if (identical(.x_env , rlang :: empty_env())) {
90+ .x
91+ } else {
92+ .x_new_env <- rlang :: env_bury(.x_env , !!! data_stats )
93+ rlang :: quo_set_env(.x , .x_new_env )
94+ }
95+
96+ })
97+
98+ }
99+
86100 # sub in arguments to actual syntax for corresponding engine
87101 object <- translate(object , engine = object $ engine )
88102
@@ -96,15 +110,6 @@ xy_xy <- function(object, env, control, target = "none", ...) {
96110 stop(" Invalid data type target: " , target )
97111 )
98112
99- if (make_descr(object )) {
100- data_stats <- get_descr_xy(env $ x , env $ y )
101- env $ n_obs <- data_stats $ obs
102- env $ n_cols <- data_stats $ cols
103- env $ n_preds <- data_stats $ preds
104- env $ n_levs <- data_stats $ levs
105- env $ n_facts <- data_stats $ facts
106- }
107-
108113 fit_call <- make_call(
109114 fun = object $ method $ fit $ func [" fun" ],
110115 ns = object $ method $ fit $ func [" pkg" ],
@@ -126,6 +131,7 @@ xy_xy <- function(object, env, control, target = "none", ...) {
126131
127132form_xy <- function (object , control , env ,
128133 target = " none" , ... ) {
134+
129135 data_obj <- convert_form_to_xy_fit(
130136 formula = env $ formula ,
131137 data = env $ data ,
0 commit comments