rmNAcols: Remove Columns with Missing Data

Description Usage Arguments Value Author(s) See Also Examples

View source: R/rmNA.R

Description

Remove columns containing missing values from a data frame or a matrix

Usage

1
2
rmNAcols(dat, rows = NULL, tolerance = 0, cumulate = TRUE, 
            remove = TRUE, verbose = FALSE)

Arguments

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 rows

cumulate

if TRUE, tolerance is cumulated; if FALSE, exact tolerance is used

remove

if TRUE columns and rows are removed, if FALSE identified columns are returned

verbose

if TRUE the removed columns are printed on the console

Value

depends on option remove

Author(s)

Martin Hecht

See Also

calls rmNA and rmNArows

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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)

eatTools documentation built on May 2, 2019, 4:44 p.m.

Related to rmNAcols in eatTools...