rmNArows: remove NA rows from data

Description Usage Arguments Value Author(s) See Also Examples

View source: R/rmNA.R

Description

remove rows that are completely or partially NA from data.frame or matrix

Usage

1
2
rmNArows(dat, cols = NULL, tolerance = 0, cumulate = TRUE, 
        remove = TRUE, verbose = FALSE)

Arguments

dat

data.frame or matrix

cols

columns to include, can be a list of vectors to specify column subsets

tolerance

number of non-NA cells that are "tolerated", can be a list corresponding to cols

cumulate

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

remove

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

verbose

if TRUE removed columns and rows are printed on output window

Value

depends on option remove

Author(s)

Martin Hecht

See Also

calls rmNA and rmNAcols

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
29
# example matrix
(mat <- matrix(c( 1,1,1,1,1, 1,1,1,1,NA, 1,1,1,NA,NA, 1,1,NA,NA,NA, 
  1,NA,NA,NA,NA, NA,NA,NA,NA,NA), ncol=5, byrow=TRUE))

# remove row with entirely NA (row 6)
rmNArows(mat, verbose = TRUE)

# remove row with NA on column 3, 4, 5 (rows 4, 5, 6)
rmNArows(mat, c(3,4,5), verbose = TRUE) 
rmNArows(mat, c(-1,-2), verbose = TRUE) 

# tolerance=1 , 1 non-NA is permitted (rows 5 and 6)
rmNArows(mat, tolerance=1, verbose = TRUE) 

# tolerance=5 , 5 non-NA are permitted (all rows are removed)
rmNArows(mat, tolerance=5, verbose = TRUE) 

# do not cumulate / exact tolerance (row 1 is removed)
rmNArows(mat, tolerance=5, cumulate=FALSE, verbose = TRUE) 
rmNArows(mat, tolerance=5, cumulate=FALSE, remove = FALSE) 

# two subsets of columns
rmNArows(mat, cols = list(c(1, 2), c(4, 5)), verbose = TRUE)

# two subsets of columns with different tolerance
rmNArows(mat, cols = list(c(1), c(2, 3, 4, 5)), tolerance = list(0, 1), verbose = TRUE)

# identify rows, no deletion
rmNArows(mat, cols = list(c(1), c(2, 3, 4, 5)), tolerance = list(0, 1), remove = FALSE)

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

Related to rmNArows in eatTools...