Delete cases with set amount of missing values

delete_na(df, n = ncol(df) - 1)

Arguments

df

A data.frame,

n

Number of NAs allowed, defaults to ncol(df) - 1.

Value

A filtered version of the input data.frame.

Note

Adapted from http://stackoverflow.com/a/30461945/409362.

Examples

not_run({ df <- data.frame(x = sample(c(1:10, NA), 10), y = sample(c(1:10, NA), 10), z = sample(c(1:10, NA), 10)) df <- delete_na(df, 1) # Or with magrittr syntax sugar df %<>% delete_na })