filter_missing {framecleaner}R Documentation

filter out missings

Description

More complex wrapper around dplyr::filter(!is.na()) to remove NA rows using tidyselect. If any specified column contains an NA the whole row is removed. Reports the amount of rows removed containing NaN, NA, Inf, in that order. For example if one row contains Inf in one column and in another, the removed row will be counted in the NA tally.

Usage

filter_missing(.data, ..., remove_inf = TRUE)

## S3 method for class 'data.frame'
filter_missing(.data, ..., remove_inf = TRUE, condition = c("any", "all"))

Arguments

.data

dataframe

...

tidyselect. default selection is all columns

remove_inf

logical. default is to also remove Inf values. set to FALSE otherwise.

condition

defaults to "any". in which case removes rows if NA is in any specified column. "all" will remove rows only if each specified column is missing

Details

S3 method, can also be used on vectors

Value

data frame

Examples


tibble::tibble(x = c(NA, 1L, 2L, NA, NaN, 5L, Inf),
y = c(1L, NA, 2L, NA, Inf, 5L, Inf)) -> tbl1

tbl1

# remove any row with a missing or Inf
tbl1 %>%
filter_missing()

# remove any row with Na or NaN in the x column
tbl1 %>%
filter_missing(x, remove_inf = FALSE)

# only remove rows where every entry is Na, NaN, or Inf
tbl1 %>%
filter_missing(condition = "all")

[Package framecleaner version 0.2.1 Index]