ez.dropna: keep rows that have a certain number (range) of NAs...

View source: R/frame.R

ez.dropnaR Documentation

keep rows that have a certain number (range) of NAs anywhere/somewhere and delete others

Description

could also accept a vector/factor as input, if so, then col,n,reindex ignored (factor->char->factor)

Usage

ez.dropna(x, col = NULL, n = 0, reindex = TRUE, print2scr = TRUE)

Arguments

x

a data frame, or a vector

col

internally evaluated by eval('dplyr::select()'), restrict to the columns where you would like to search for NA; eg, 3, c(3), 2:5, "place", c("place","age")
default is NULL, search for all columns.

n

integer or vector, 0, c(3,5), number/range of NAs allowed.
If a number, the exact number of NAs kept
Range includes both ends 3<=n<=5
Range could be -Inf, Inf

reindex

whether to keep original row index or reindex
eg, original row.names() is 1, 2, 3, then drop row 2
if not reindex, new index is 1, 3
if reindex, new index is 1, 2

print2scr

T/F. if T, print out rows containing NAs dropped (In: -> Out: )

Value

returns a new df with rows that have NA(s) removed, or a new vector/factor without NAs


jerryzhujian9/ezmisc documentation built on March 9, 2024, 12:44 a.m.