Skip to content

Commit

Permalink
Slighltly improve coefnames with no intercept
Browse files Browse the repository at this point in the history
Adopt improvements from `termnames`.
  • Loading branch information
nalimilan authored Sep 7, 2023
1 parent 1632bff commit 9eb7772
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/terms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,15 @@ vectorize(x) = [x]
"""
coefnames(term::AbstractTerm)
Return the name(s) of column(s) generated by a term. Return value is either a
`String` or an iterable of `String`s.
Return the name(s) of column(s) generated by a term.
Return value is either a `String`, an iterable of `String`s or the empty vector
if there is no associated column (e.g. `coefnames(InterceptTerm{false}())`).
See also [`termnames`](@ref).
"""
StatsAPI.coefnames(t::FormulaTerm) = (coefnames(t.lhs), coefnames(t.rhs))
StatsAPI.coefnames(::InterceptTerm{H}) where {H} = H ? "(Intercept)" : []
StatsAPI.coefnames(::InterceptTerm{H}) where {H} = H ? "(Intercept)" : String[]
StatsAPI.coefnames(t::ContinuousTerm) = string(t.sym)
StatsAPI.coefnames(t::CategoricalTerm) =
["$(t.sym): $name" for name in t.contrasts.coefnames]
Expand Down

0 comments on commit 9eb7772

Please sign in to comment.