rmNARow: Remove rows that have NA in certain columns

View source: R/rmNARow.R

rmNARowR Documentation

Remove rows that have NA in certain columns

Description

Remove all rows that have an NA in at least one of the specified columns.

Usage

rmNARow(data_dt, cols_v = NULL, extract_v = F)

Arguments

data_dt

data.table or data.frame to have rows removed

cols_v

columns to check for NA in. If NULL (default) will check all columns

extract_v

logical, TRUE - output the NA rows; FALSE (default) - output the input table with NA rows removed

Value

data.table either containing the offending rows (extract_v == T), or the input table with those rows removed

Examples

data_df <- data.frame("A" = 1:5, "B" = c(1,2,NA,4,5), "C" = c(NA,2:5), "D" = c(1:4,NA))
rmNARow(data_dt = data_df, cols_v = "A")
rmNARow(data_dt = data_df, cols_v = c("A", "B"))
rmNARow(data_dt = data_df)
rmNARow(data_dt = data_df, extract_v = T)

weshorton/wrh.rUtils documentation built on Oct. 28, 2024, 7:24 a.m.