rmEmptyCol: Remove Empty columns from data.frame or matrix

Description Usage Arguments Value Author(s) Examples

View source: R/rmEmptyCol.R

Description

This function takes a data.frame or matrix and looks for columns containing no data. This is judged by all elements in a column containing only NAs, NaNs or empty strings, which maybe user defined. Columns can be removed when containing a mixture of things judged to contain no data. Currently lists are not supported. haven library reads .sas7bdat files and returns them as lists. Such would need to be converted to data.frames.

Usage

1
rmEmptyCol(d, na.strings = ".")

Arguments

d

a data.frame or matrix

na.strings

a character vector of strings that should be considered as NA. Regular expressions are not supported. Strings are matched exactly: "." is not the same as ". "

Value

A data.frame or matrix as was supplied, with any empty columns removed.

Author(s)

Aaron Hayman

Examples

1
2
d = data.frame(a=1:100000,b=NA,c=runif(100000),d='.',e=sample(c('.',NA,'NA',NaN,''),100000,TRUE))
e = rmEmptyCol(d)

jgrevel/BAST1-R-Library documentation built on May 21, 2019, 10:11 a.m.