This seems to be a consequence of the promote_rule for NA, as defined in
https://github.com/JuliaStats/DataArrays.jl/blob/fc8a8a1f7713c61c76a3562f17fba8c0d193c82b/src/natype.jl#L36-L37
It even has a TODO comment, so it is obvious that the author did not like
his solution, but had some reason to define NA to promote to any type you
combine it with.
I'm not sure what this rule should be, but the current choice is definitely
bad for concatenation of elements to an array.
Regards Ivar
kl. 05:09:22 UTC+2 onsdag 21. mai 2014 skrev Paulo Castro følgende:
>
> Hi there,
>
> I'm using DataFrames package and having problems using NA on Array{Any}.
> Here is the thing:
>
> julia> a = [true 2 "hi"]
> 1x3 Array{Any,2}:
> true 2 "hi"
>
> That's expected, Julia had no way to promote this elements to a single
> concrete type, so I got an Array{Any}. Now, if I try:
>
> julia> a[3] = NA
> 1x3 Array{Any,2}:
> true 2 NA
>
> Thats also expected! NA is of NAType, that is a subtype of Any (as any
> other type). But if I try:
>
> julia> a = [true 2 NA]
> ERROR: no method convert(Type{Int64}, NAtype)
> in setindex! at multidimensional.jl:63
> in cat at abstractarray.jl:625
> in hcat at abstractarray.jl:632
>
> That's unexpected. What am I missing?
>
> Thanks and sorry about my poor English.
>