Constructing a formula on the fly requires you to learn a bit about the structure of the formula itself.
julia> ff = foo ~ bar + baz
Formula: foo ~ bar + baz
julia> fieldnames(ff)
2-element Array{Symbol,1}:
:lhs
:rhs
julia> typeof(ff.lhs)
Symbol
Suppose instead that you want to have "fab" on the left hand side. You can simply reassign the .lhs member as the symbol
julia> ff.lhs = symbol("fab")
:fab
julia> ff
Formula: fab ~ bar + baz
The right-hand side is a bit more complicated in that it is an expression.
julia> ff.rhs
:(bar + baz)
julia> typeof(ff.rhs)
Expr
julia> fieldnames(ff.rhs)
3-element Array{Symbol,1}:
:head
:args
:typ
julia> ff.rhs.args
3-element Array{Any,1}:
:+
:bar
:baz
Now it happens that the + function can take an arbitrary number of arguments. I can change the formula to "fab ~ 1 + baz + boz" with
julia> ff.rhs.args = Any[:+, 1, :baz, :box]
4-element Array{Any,1}:
:+
1
:baz
:box
julia> ff
Formula: fab ~ 1 + baz + box
Does this help?