Skip to contents

Aborts when data has missing values on non-nullable columns

Usage

abort_if_incomplete(data, non_nullable_cols = names(data))

Arguments

data

Tibble holding a result data set.

non_nullable_cols

A character vector holding names of columns on which NAs are not allowed.

Value

Input data invisibly.

Examples

data <- tibble::tibble(x = NA, y = 1, z = NA)

# With NA in nullable columns returns data invisibly
data %>% abort_if_incomplete(non_nullable_cols = "y")
out <- data %>% abort_if_incomplete(non_nullable_cols = "y")
identical(out, data)
#> [1] TRUE

# With NA in one nullable column, alerts the column to review as an error
data %>%
  abort_if_incomplete(non_nullable_cols = c("x", "y")) %>%
  try()
#> Error in abort_if_incomplete(., non_nullable_cols = c("x", "y")) : 
#>   Non-nullable columns must not have `NA`s.
#>  Columns to review: x

# By default, it takes all columns as non-nullable
data %>%
  abort_if_incomplete() %>%
  try()
#> Error in abort_if_incomplete(.) : 
#>   Non-nullable columns must not have `NA`s.
#>  Columns to review: x, z