Skip to content

Incorrect Default Coding of Union{Missing, Int or Float64} #145

@clintonTE

Description

@clintonTE

Pretty straight forward. I would expect the results of these to be the same:

function mwe(N=10)
  df = DataFrame(x = rand(N),
    zm = Vector{Union{Missing, Int}}(rand(1:4,N)),
    z = Vector{Int}(rand(1:4,N)))

  println("W/out missings")
  f = @eval(@formula(x ~ z))
  f = apply_schema(f, schema(f,df), StatisticalModel)
  m = modelcols(f.rhs, df)
  display(m)

  println("With missings")
  f = @eval(@formula(x ~ zm))
  f = apply_schema(f, schema(f,df), StatisticalModel)
  m = modelcols(f.rhs, df)
  display(m)
end

mwe()

OUTPUT:

W/out missings
10×2 Array{Float64,2}:
 1.0  3.0
 1.0  3.0
 1.0  2.0
 1.0  2.0
 1.0  1.0
 1.0  2.0
 1.0  4.0
 1.0  1.0
 1.0  4.0

With missings
10×4 Array{Float64,2}:
 1.0  0.0  1.0  0.0
 1.0  0.0  1.0  0.0
 1.0  0.0  0.0  0.0
 1.0  0.0  0.0  0.0
 1.0  0.0  1.0  0.0
 1.0  0.0  0.0  0.0
 1.0  0.0  1.0  0.0
 1.0  1.0  0.0  0.0
 1.0  0.0  0.0  1.0
 1.0  0.0  1.0  0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions