diff --git a/src/terms.jl b/src/terms.jl index 188120b1..dd41aadf 100644 --- a/src/terms.jl +++ b/src/terms.jl @@ -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]