Questions about missing

julia> a=[true,false,true,true,missing]
5-element Vector{Union{Missing, Bool}}:
  true
 false
  true
  true
      missing
julia> mean(skipmissing(a))
0.75
julia> length(a)
5
julia> length(skipmissing(a))
ERROR: MethodError: no method matching length(::Base.SkipMissing{Vector{Union{Missing, Bool}}})

I want to calculate the length without missing in a,and only count the true and false ,then return 4.What should I do ? Thanks for helping me.

You can use collect

julia> length(collect(skipmissing([1,2,missing,4])))
3
1 Like

Or (probably more efficient)

count(!ismissing, a)
6 Likes