@@ -20,8 +20,8 @@ y_lvl <- function(rec) {
20
20
}
21
21
var_roles <- summary(rec )
22
22
y_cols <- var_roles $ variable [var_roles $ role == " outcome" ]
23
- y_dat <- rec $ template % > %
24
- dplyr :: select(one_of(y_cols )) % > %
23
+ y_dat <- rec $ template | >
24
+ dplyr :: select(one_of(y_cols )) | >
25
25
dplyr :: pull(1 )
26
26
length(levels(y_dat ))
27
27
}
@@ -57,14 +57,14 @@ chr_assign <- function(name, value, cr = TRUE) {
57
57
res
58
58
}
59
59
pipe_value <- function (base , value ) {
60
- # Find last non-comment line, add a `%>% ` to the end, then add another line
60
+ # Find last non-comment line, add a `|> ` to the end, then add another line
61
61
value <- rlang :: enexpr(value )
62
62
value <- rlang :: expr_text(value , width = expr_width )
63
63
clean_base <- gsub(" \\ n" , " " , base )
64
64
clean_base <- trimws(base , which = " left" )
65
65
not_comment <- seq_along(base )[! grepl(" ## " , clean_base )]
66
66
n <- max(1 , max(not_comment ))
67
- base [n ] <- paste(base [n ], " %>% " )
67
+ base [n ] <- paste(base [n ], " |> " )
68
68
c(base , paste0(" \n " , value ))
69
69
}
70
70
add_comment <- function (base , value , add = TRUE , colors = TRUE ) {
@@ -84,38 +84,38 @@ add_comment <- function(base, value, add = TRUE, colors = TRUE) {
84
84
res
85
85
}
86
86
add_steps_dummy_vars <- function (base , hot = FALSE , add = FALSE , colors = TRUE ) {
87
- base <- base % > %
87
+ base <- base | >
88
88
pipe_value(step_novel(all_nominal_predictors()))
89
89
if (hot ) {
90
- base <- base % > %
91
- add_comment(dummy_hot_msg , add , colors = colors ) % > %
90
+ base <- base | >
91
+ add_comment(dummy_hot_msg , add , colors = colors ) | >
92
92
pipe_value(step_dummy(all_nominal_predictors(), one_hot = TRUE ))
93
93
} else {
94
- base <- base % > %
95
- add_comment(dummy_msg , add , colors = colors ) % > %
94
+ base <- base | >
95
+ add_comment(dummy_msg , add , colors = colors ) | >
96
96
pipe_value(step_dummy(all_nominal_predictors()))
97
97
}
98
98
base
99
99
}
100
100
add_steps_normalization <- function (base ) {
101
- base % > %
102
- pipe_value(step_zv(all_predictors())) % > %
101
+ base | >
102
+ pipe_value(step_zv(all_predictors())) | >
103
103
pipe_value(step_normalize(all_numeric_predictors()))
104
104
}
105
105
factor_check <- function (base , rec , add , colors = TRUE ) {
106
106
var_roles <- summary(rec )
107
107
nominal <- var_roles $ variable [var_roles $ type == " nominal" ]
108
108
is_str <-
109
109
purrr :: map_lgl(
110
- rec $ template % > % dplyr :: select(dplyr :: one_of(nominal )),
110
+ rec $ template | > dplyr :: select(dplyr :: one_of(nominal )),
111
111
rlang :: is_character
112
112
)
113
113
if (any(is_str )) {
114
114
selector <- rlang :: expr(one_of(!!! nominal [is_str ]))
115
115
step_expr <- rlang :: expr(step_string2factor(!! selector ))
116
116
base <-
117
- base % > %
118
- add_comment(string_to_factor_msg , add = add , colors = colors ) % > %
117
+ base | >
118
+ add_comment(string_to_factor_msg , add = add , colors = colors ) | >
119
119
pipe_value(!! step_expr )
120
120
}
121
121
base
@@ -135,9 +135,9 @@ top_level_comment <- function(..., add = FALSE, colors = TRUE) {
135
135
}
136
136
137
137
template_workflow <- function (prefix ) {
138
- paste0(prefix , " _workflow" ) % > %
139
- assign_value(workflow()) % > %
140
- pipe_value(add_recipe(!! rlang :: sym(paste0(prefix , " _recipe" )))) % > %
138
+ paste0(prefix , " _workflow" ) | >
139
+ assign_value(workflow()) | >
140
+ pipe_value(add_recipe(!! rlang :: sym(paste0(prefix , " _recipe" )))) | >
141
141
pipe_value(add_model(!! rlang :: sym(paste0(prefix , " _spec" ))))
142
142
}
143
143
0 commit comments