delete_na: Delete cases with set amount of missing values

Description Usage Arguments Value Note Examples

View source: R/cleanup_helpers.R

Description

Delete cases with set amount of missing values

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
set.seed(1445)
dat <- data.frame(
  x = sample(c(1:15, NA, NA), 15),
  y = sample(c(1:15, NA, NA), 15),
  z = sample(c(1:15, NA, NA), 15)
)
dat
# No NsA per row allowed
delete_na(dat, 0)
# One NA per row allowed
delete_na(dat, 1)

tadaatoolbox documentation built on July 2, 2020, 2:30 a.m.