Skip to content

filter option to keep NAs #6432

@spressi

Description

@spressi

Hey there,
I'd like to propose to add a parameter to dplyr::filter to specify how NAs are treated in the logical vector.
From the documentation: "Note that when a condition evaluates to NA the row will be dropped, unlike base subsetting with [."
While this is a good default behavior, it would be nice to be able to add, e.g. .treat.nas=T to the function call to emulate base R subsetting in a convenient way.

Use case / reprex: Looking for inconsistencies in data, you sometimes want to show NAs:

tibble(col1 = 1:3, col2 = c(1, 1, NA)) %>% filter(col1 != col2)

This call only outputs row 2 but it would be nice to be able to obtain row 3 as well if desired.

Thanks and kind regards,
Mario

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions