Learn R Programming

tern (version 0.9.12)

get_complete_cases: Remove rows with missing values

Description

[Experimental]

Remove rows containing one or more missing values from a data frame. If any rows are omitted, a warning is issued reporting the number of removed rows, unless quiet is TRUE.

Usage

get_complete_cases(df, quiet = FALSE, additional_message = ".")

Value

A data.frame containing only complete rows. The original column structure is preserved. If no rows contain missing values, df is returned unchanged.

Arguments

df

(data.frame)
A data frame.

quiet

(logical(1))
Whether to suppress the warning when rows with missing values are omitted.

additional_message

(character(1))
A message appended to the default warning. The default warning reports the number of rows removed.

Details

A row is considered incomplete if at least one of its values is missing. Missingness is determined using stats::complete.cases().

If one or more rows contain missing values, those rows are omitted and a warning is issued reporting the number of omitted rows, unless quiet is TRUE. The value of additional_message is appended to the warning message.

If no rows contain missing values, df is returned unchanged and no warning is issued.

Examples

Run this code
df <- data.frame(a = c(1:5, NA), b = c(NA, letters[1:5]))
df

get_complete_cases(df)

Run the code above in your browser using DataLab