removeVariable: Remove variables containing NaNs or NAs from data.frames.

Description Usage Arguments Value Examples

View source: R/removeVariable.R

Description

In reading data, incomplete variables are sometimes included, and only NAs or NaNs are included in some variables. This function removes such variables in the data.frame. In addition to NAs or NaNs, variables which contain specified keyword can also be removed.

Usage

1
removeVariable(data = NULL, string = NA, na.prop = 1, nan.prop = 1)

Arguments

data

a data.frame from which variables are removed.

string

a flag character specifying variables to be removed.

na.prop

a numeric value specifying NA threshold proportion for removing variables. The default threashold is 1.0, meaning that variables including only NAs are removed.

nan.prop

a numeric value specifying NaN threshold proportion for removing variables. The default threashold is 1.0, meaning that variables including only NaNs are removed.

Value

a data.frame from which some variables are removed.

Examples

1
2
3
4
df <- data.frame(imcomp=rep(NA, 10), imcomp2=rep(NaN, 10), cov1=rnorm(10), NO_USE=rnorm(10))
df2 <- removeVariable(df, string="NO_USE")
str(df)
str(df2)

epifit documentation built on May 29, 2017, 3:43 p.m.