Proper way to initiate an array with `missing`

question

#1

pretty simple question with no documentation that I could find. is this the right way to get a 3x1 array of missings that at some point I may want to fill with with Int?

julia> x = Union{Int64, Missings.Missing}[missing for i in 1:3]
3-element Array{Union{Int64, Missings.Missing},1}:
 missing
 missing
 missing

julia> x[2] = 1
1

the other way I could think is a bit contrived, given that I would like to initiate to missing

julia> x=Vector{Union{Int64, Missings.Missing}}(3)
3-element Array{Union{Int64, Missings.Missing},1}:
 #undef
 #undef
 #undef

julia> x[2] = 1
1

julia> x[1] = missing
missing

julia> x
3-element Array{Union{Int64, Missings.Missing},1}:
    missing
   1       
 #undef    

cheers


#2
julia> Vector{Union{Int,Missing}}(missing, 3)
3-element Array{Union{Missing, Int64},1}:
 missing
 missing
 missing

#3

Perhaps

convert(Array{Union{Missing, Int}}, fill(missing, 3, 1))

or

fill!(Array{Union{Missing, Int}}(3, 1), missing)

but it is not much better. I wish fill would take a type argument.


#4

Either

using Missings
missings(Int64, 10)

or:

using DataArrays
DataArray(Int64, 10)

if you want a DataArray


#5

How about

missings(Int64, 3)

This should work for any type.


#6

i like that most, thanks! had no idea how to use the Missings.jl package.