Skip to content

skipping missing values #97

Description

@s-celles

Hello,

according doc

In many cases, missing values will have to be skipped or replaced with a valid value. For example, sum([1, missing]) returns missing due to the behavior of +. Use sum(Missings.skip([1, missing]) to ignore missing values.

using Missings
sum(Missings.skip([1, missing])

is problematic (ending parenthesis is missing) but

sum(Missings.skip([1, missing]))

raises

ERROR: MethodError: no method matching skip(::Array{Union{Missing, Int64},1})

Doc (and maybe code also) should be fixed.

Maybe it should be

julia> sum(filter(!ismissing, [1, missing, 2]))
3

or with iterator

julia> sum(Iterators.filter(!ismissing, [1, missing, 2]))
3

I will personally define Missings.skip like

julia> skip(a, Missing) = Iterators.filter(!ismissing, a)
skip (generic function with 1 method)

julia> sum(skip([1, missing, 2], missing))
3

Kind regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions