A missing value represents data that exists in the real world but was not recorded, was lost, or is otherwise unknown. Julia represents it with the missing object, whose type is Missing. This differs from nothing: nothing means that something does not exist, while missing means that its value is unavailable. section 10.3 section 10.6
Missing values propagate through calculations instead of immediately throwing an exception. For example, 10 + missing evaluates to missing, warning that the result cannot be known. This behavior helps expose unnoticed gaps in statistical or scientific data. section 10.3
Summarizing incomplete data
Given xs = [2, missing, 4, 8], sum(xs) returns missing because the input is incomplete. To calculate over the known values, use sum(skipmissing(xs)), which returns 14; mean(skipmissing(xs)) and median(skipmissing(xs)) similarly exclude the missing entry. section 10.3
Keep these unknown-value cases separate:
- Use missing for unavailable input data, such as an unanswered survey field or an incomplete experiment. section 10.7
- Use nothing when a result or object does not exist, such as a failed search result. section 10.0 section 10.6
- Treat NaN as the result of an illegal mathematical operation and undefined as an uninitialized variable, not as missing data. section 10.6 section 10.7
Listing 10.4 Comparing behavior of missing and nothing in mathematical expressions
julia> missing < 10 missing julia> nothing < 10 ERROR: MethodError: no method matching isless(::Nothing, ::Int64) julia> 10 + missing missing julia> 10 + nothing ERROR: MethodError: no method matching +(::Int64, ::Nothing)
Compare how missing propagates through comparisons and arithmetic while nothing produces method errors. section 10.3
julia> using Statistics julia> xs = [2, missing, 4, 8]; julia> sum(xs) #1 missing julia> sum(skipmissing(xs)) #2 14 julia> median(skipmissing(xs)) 4.0 julia> mean(skipmissing(xs)) 4.666666666666667
Run compact Julia examples showing how skipmissing supports sums, medians, and means over incomplete arrays. section 10.3


































