Allowing a preexisting vector to contain missings later on


A = [1.0, 2.0]
A = Union{Float64,Missing}[1.0, 2.0]
A[1] = missing          # Union{Missing, Float64}[missing, 2.0]


B = [1.0, 2.0]
missB = Union{Float64,Missing}B        # errors

How may I accomplish this? Thank you in advance.


the syntax of T[1,2,3] works because getindex(T, 1,2,3) is understood (specially) as making a vector of element type T. The TB is understood to be T*B which doesn’t make sense.

1 Like

@jling thank you for your reply. Now I am getting ERROR: LoadError: MethodError: no method matching Union{Missing, Float64}(::Vector{Float64})

can you post complete code?

you forgot the Array?

1 Like

Yes, I forgot it! Thank you very much for your help

You can also use allowmissing(v)

isn’t that from like DataFrame?

Yes but its defined for arrays as well in Missings.jl (I didn’t realize it was in Missings earlier)