View source: R/filter_missing.R
| filter_missing | R Documentation |
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.
filter_missing(.data, ..., remove_inf = TRUE)
## S3 method for class 'data.frame'
filter_missing(.data, ..., remove_inf = TRUE, condition = c("any", "all"))
.data |
dataframe |
... |
tidyselect. default selection is all columns |
remove_inf |
logical. default is to also remove |
condition |
defaults to "any". in which case removes rows if |
S3 method, can also be used on vectors
data frame
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.