How to use all variable in @formula like R language?

out <- glm(y ~ . , family=binomial(),data=turnout)

In R, above syntax works and i expected that’s similar to julia, but . is not a proper symbol in GLM.jl maybe.

julia> out = glm(@formula(y ~ .), train, Binomial())
ERROR: syntax: invalid identifier name "."

dup of

Thanks, but your solution is written at 2 years ago and i’ll very happy if there exists a better way. Is that still the best?

Yes, still the best way.

Well, the way it’s written is awkward.


julia> term(:y) ~ sum(term.(names(df, Not(:y))))
FormulaTerm
Response:
  y(unknown)
Predictors:
  x1(unknown)
  x2(unknown)
1 Like

Ha, I guess something did change in the intervening period and I should have known

2 Likes