Reputation: 16064
In R the NA value is available by default however in Julia when I tried
function a()::Array{Union{Int64,Null})
return [1, null, 2]
end
a()
it gives the error
UndefVarError: Null not defined
How do I use null in Julia?
Upvotes: 2
Views: 1684
Reputation: 26
For any future readers of this question, this has been resolved in v1 via the missing
object.
function a()::Array{Union{Int64, Missing}}
return [1, missing, 2]
end
You can use the skipmissing
function with array operators if you wish to ignore any missing
values.
Upvotes: 1
Reputation: 8044
The representation of nullable values is one of the biggest current discussions in julia, and one of the biggest hurdles for the 1.0 version step. The easiest at the moment is probably to use the NA
defined in DataFrames (which uses DataArrays)
function a()::DataArray{Int64}
return @data [1, NA, 2]
end
Read also https://juliadata.github.io/DataFrames.jl/stable/man/getting_started/#The-NA-Value-1
Upvotes: 4