Skip to content

Commit

Permalink
don't sort, use intersect to grab order from levels
Browse files Browse the repository at this point in the history
  • Loading branch information
kleinschmidt committed Apr 16, 2018
1 parent 26b4f4d commit e612929
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/modelframe.jl
Expand Up @@ -102,9 +102,10 @@ end

const DEFAULT_CONTRASTS = DummyCoding

_unique(x::AbstractCategoricalArray) = sort!(unique(x))
# get unique values, honoring levels order
_unique(x::AbstractCategoricalArray) = intersect(levels(x), unique(x))
_unique(x::AbstractCategoricalArray{T}) where {T>:Missing} =
convert(Array{Missings.T(T)}, filter!(!ismissing, sort!(unique(x))))
convert(Array{Missings.T(T)}, filter!(!ismissing, intersect(levels(x), unique(x))))

function _unique(x::AbstractArray{T}) where T
levs = T >: Missing ?
Expand Down

0 comments on commit e612929

Please sign in to comment.