You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be an issue with the step_interact() function when attempting to create multiple interactions and two of the variable names have more than a certain number of characters (12 to 14?) is specified as the first interaction, but not when specifying it as the second interaction.
Reproducible example
I originally ran into the problem when using two variables with the 14 characters in the name where Interactions with: gives ... which leads to the error in rlang::f_rhs() when calling prep().
library(recipes)
#> Loading required package: dplyr#> #> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#> #> filter, lag#> The following objects are masked from 'package:base':#> #> intersect, setdiff, setequal, union#> #> Attaching package: 'recipes'#> The following object is masked from 'package:stats':#> #> stepdf<-data.frame(
a=1:10,
bbbbbbbbbbbbbb=1:10, # 14cccccccccccccc=1:10, # 14d=1:10
)
# error
recipe(df) %>%
step_interact(~starts_with('bbbbbbbbbbbbbb'):starts_with('cccccccccccccc') + starts_with('bbbbbbbbbbbbbb'):starts_with('d')) %>%
prep(training=df)
#> Warning: Interaction specification failed for: ~.... No interactions will be#> created.#> Error in `step_interact()`:#> Caused by error in `rlang::f_rhs()`:#> ! `x` must be a formula
Recipe output without prep:
recipe(df) %>%
step_interact(~starts_with('bbbbbbbbbbbbbb'):starts_with('cccccccccccccc') + starts_with('bbbbbbbbbbbbbb'):starts_with('d'))
#> #> -- Recipe ----------------------------------------------------------------------#> #> -- Inputs#> Number of variables by role#> undeclared role: 4#> #> -- Operations#> * Interactions with: ...
Switching the order of specifying the interaction allows it to work.
I then proceeded to try to find a pattern for the error, but have been unable to discern anything from my attempt.
The following are additional things I tried for finding a pattern. The ones that worked are denoted with # yes and the ones that gave Interactions with: ... are denoted with # no:
The text was updated successfully, but these errors were encountered:
ray-p144
changed the title
Error in starts_with and step_interect related to length of variable name and order
Error in starts_with and step_interact related to length of variable name and order
Oct 5, 2023
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex https://reprex.tidyverse.org) and link to this issue.
The problem
There seems to be an issue with the
step_interact()
function when attempting to create multiple interactions and two of the variable names have more than a certain number of characters (12 to 14?) is specified as the first interaction, but not when specifying it as the second interaction.Reproducible example
I originally ran into the problem when using two variables with the 14 characters in the name where
Interactions with:
gives...
which leads to the error inrlang::f_rhs()
when callingprep()
.Recipe output without prep:
Switching the order of specifying the interaction allows it to work.
I then proceeded to try to find a pattern for the error, but have been unable to discern anything from my attempt.
The following are additional things I tried for finding a pattern. The ones that worked are denoted with
# yes
and the ones that gaveInteractions with: ...
are denoted with# no
:Using
matches()
instead ofstarts_with()
works.Using 14 characters in the third variable name does not work in either order.
Using 13 characters in two variables depends on the order of interactions.
Other combinations of the number of characters in variable name:
Created on 2023-10-05 by the reprex package (v2.0.1)
Session info
The text was updated successfully, but these errors were encountered: