rmNAcols {eatTools} | R Documentation |
Remove columns containing missing values from a data frame or a matrix
rmNAcols(dat, rows = NULL, tolerance = 0, cumulate = TRUE, remove = TRUE, verbose = FALSE)
dat |
A data frame or a matrix |
rows |
rows to include in evaluating the missing values of columns, can be a list of vectors to specify row subsets |
tolerance |
Number of non-NA cells that are "tolerated", can be a list corresponding to |
cumulate |
if |
remove |
if |
verbose |
if |
depends on option remove
Martin Hecht
# example matrix (mat <- matrix(c(1,1,1,1,1,1, 1,1,1,1,1,NA, 1,1,1,1,NA,NA, 1,1,1,NA,NA,NA, 1,1,NA,NA,NA,NA, 1,NA,NA,NA,NA,NA, NA,NA,NA,NA,NA,NA), ncol=7)) # remove column with entirely NA (column 7) rmNAcols(mat, verbose = TRUE) # remove column with NA on rows 3, 4, 5 (columns 5, 6, 7) rmNAcols(mat, c(3,4,5), verbose = TRUE) rmNAcols(mat, c(-1,-2,-6), verbose = TRUE) # tolerance=1 , 1 non-NA is permitted (columns 6 and 7) rmNAcols(mat, tolerance=1, verbose = TRUE) # tolerance=6 , 6 non-NA are permitted (all columns are removed) rmNAcols(mat, tolerance=6, verbose = TRUE) # do not cumulate / exact tolerance (column 1) rmNAcols(mat, tolerance=6, cumulate=FALSE, verbose = TRUE) # two subsets of rows rmNAcols(mat, rows = list(c(1, 2), c(4, 5)), verbose = TRUE) # two subsets of rows with different tolerance rmNAcols(mat, rows = list( 1, c(2, 3, 4, 5)), tolerance = list(0, 1), verbose = TRUE) # identify cols, no deletion rmNAcols(mat, rows = list(c(1, 2), c(3, 4, 5)), tolerance = list(0, 1), remove = FALSE)