The Julia 1.0.0 documentation says this about missing values in Julia and R:
In Julia, missing values are represented by the missing object rather than by NA. Use ismissing(x) instead of isna(x). The skipmissing function is generally used instead of na.rm=TRUE (though in some particular cases functions take a skipmissing argument).
Here is example code in R that I would like to duplicate in Julia:
> v = c(1, 2, NA, 4)
> is.na(v)
[1] FALSE FALSE TRUE FALSE
(First note that is.na
is the R function's correct spelling, not isna
as shown in the quote above, but that is not my point.)
If I follow the documentation's suggestion to use ismissing
in Julia, I get a different type of result than in R.
julia> v = [1, 2, missing, 4]
4-element Array{Union{Missing, Int64},1}:
1
2
missing
4
# Note that based on R, I was expecting: `false false true false`
# though obviously in a different output format.
julia> ismissing(v)
false
To duplicate the R code, I seem to have to do something like:
julia> [ismissing(x) for x in v]
4-element Array{Bool,1}:
false
false
true
false
That works, but it is not as succinct as is.na
in R. Maybe I am missing something.
I also tried:
julia> ismissing(v[:])
false
julia> ismissing(v[1:end])
false
Any suggestions?
You can broadcast
ismissing
with.
: