@@ -19,23 +19,23 @@ varying <- function()
1919# ' library(dplyr)
2020# ' library(rlang)
2121# '
22- # ' # rand_forest() %>% varying_args(id = "plain")
22+ # ' rand_forest() %>% varying_args(id = "plain")
2323# '
24- # ' # rand_forest(mtry = varying()) %>% varying_args(id = "one arg")
24+ # ' rand_forest(mtry = varying()) %>% varying_args(id = "one arg")
2525# '
26- # ' # rand_forest(others = list(sample.fraction = varying())) %>%
27- # ' # varying_args(id = "only others")
26+ # ' rand_forest(others = list(sample.fraction = varying())) %>%
27+ # ' varying_args(id = "only others")
2828# '
29- # ' # rand_forest(
30- # ' # others = list(
31- # ' # strata = expr(Class),
32- # ' # sampsize = c(varying(), varying())
33- # ' # )
34- # ' # ) %>%
35- # ' # varying_args(id = "add an expr")
29+ # ' rand_forest(
30+ # ' others = list(
31+ # ' strata = expr(Class),
32+ # ' sampsize = c(varying(), varying())
33+ # ' )
34+ # ' ) %>%
35+ # ' varying_args(id = "add an expr")
3636# '
37- # ' # rand_forest(others = list(classwt = c(class1 = 1, class2 = varying()))) %>%
38- # ' # varying_args(id = "list of values")
37+ # ' rand_forest(others = list(classwt = c(class1 = 1, class2 = varying()))) %>%
38+ # ' varying_args(id = "list of values")
3939# '
4040# ' @export
4141varying_args <- function (x , id , ... )
@@ -113,6 +113,7 @@ varying_args.step <- function(x, id = NULL, ...) {
113113 x <- x [! (names(x ) %in% exclude )]
114114 x <- x [! map_lgl(x , is.null )]
115115 res <- map(x , find_varying )
116+
116117 res <- map_lgl(res , any )
117118 tibble(
118119 name = names(res ),
@@ -138,16 +139,18 @@ is_varying <- function(x) {
138139
139140# Error: C stack usage 7970880 is too close to the limit (in some cases)
140141find_varying <- function (x ) {
141- if (is.atomic(x ) | is.name(x )) {
142+ if (is_quosure(x ))
143+ x <- quo_get_expr(x )
144+ if (is_varying(x )) {
145+ return (TRUE )
146+ } else if (is.atomic(x ) | is.name(x )) {
142147 FALSE
143- } else if (is.call(x )) {
144- if (is_varying(x )) {
145- TRUE
146- } else {
147- find_varying(x )
148+ } else if (is.call(x ) || is.pairlist(x )) {
149+ for (i in seq_along(x )) {
150+ if (is_varying(x [[i ]]))
151+ return (TRUE )
148152 }
149- } else if (is.pairlist(x )) {
150- find_varying(x )
153+ FALSE
151154 } else if (is.vector(x ) | is.list(x )) {
152155 map_lgl(x , find_varying )
153156 } else {
0 commit comments