tidymodels / hardhat

Construct Modeling Packages
https://hardhat.tidymodels.org
Other
101 stars 16 forks source link

Use `expr_contains()` to better check for factor names in functions #183

Closed DavisVaughan closed 2 years ago

DavisVaughan commented 2 years ago

Closes #182 Related to #175, as we also used expr_contains() there

In the original example in #182, we would detect species as a factor column, and then in detect_factorish_in_functions() we would grepl() that against the non-factor expressions in the terms object, which included the expression that was just: xxspeciesxx, so it looked like species was part of an inline function.

We no longer use grepl(), instead moving to the (hopefully) more robust approach of iterating through the components of the expression with expr_contains() and checking them exactly.

We modified expr_contains() here to disallow matching function names in case a user has a factor column that is named the same as an inline function they used. This should be rare anyways, but seemed like a good check. We didn't have this before because we were checking for :, which was the actual function name.

github-actions[bot] commented 2 years ago

This pull request 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.