drsimonj / twidlr

data.frame-based API for model and predict functions
Other
59 stars 9 forks source link

Coerce formula arg to formula #19

Closed drsimonj closed 7 years ago

drsimonj commented 7 years ago

String operations are often used to dynamically construct formulas. Although some functions might coerce string formulas to a proper formula object first, this isn't always necessarily the case. So the option is to always coerce formula via as.formula.

drsimonj commented 7 years ago

To demonstrate

library(twidlr)
# Works:
ttest(mtcars, hp ~ am) 
ttest(mtcars, as.formula("hp ~ am"))

# Error
ttest(mtcars, "hp ~ am")