Skip to content

Commit

Permalink
unique from categoricalarrays 0.3.8 (#55)
Browse files Browse the repository at this point in the history
* sort unique values returned by unique(CategoricalArrays)

* don't sort, use intersect to grab order from levels
  • Loading branch information
kleinschmidt authored and ararslan committed Apr 17, 2018
1 parent 82d6a72 commit 9bbc2a7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/modelframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ end

const DEFAULT_CONTRASTS = DummyCoding

_unique(x::AbstractCategoricalArray) = 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, 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 9bbc2a7

Please sign in to comment.