StatsModels.jl
StatsModels.jl copied to clipboard
Preserve original expression when parsing a formula in terms2.0?
As discussed in https://github.com/JuliaInterop/RCall.jl/issues/306 I think it would be helpful to preserve a copy of the original expression passed to the @formula macro, either in the FormulaTerm type or perhaps in a Formula type that contains this expression and the FormulaTerm.
My reasons for suggesting this are twofold:
- I have users who want to have main effects, two-factor interactions, three-factor interactions, etc. and a formula like
y ~ 1 + A * B * C * D * ...
gets expanded to
y ~ 1 + A + B + C + D + ... + A & B + A & C + ...
when I include it in the show method for the fitted model.
- It is easier in the
RCallconversion from a Julia formula to an R formula is you can just grab hold of the original expression rather than needing to reconstruct it from thelhsand the expandedrhs.
Indeed, it would make sense that when printing models we show the original formula that the user typed instead of the expanded one.