Description Usage Arguments Value Author(s) See Also Examples
remove rows that are completely or partially NA from data.frame or matrix
1 2 |
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 |
cumulate |
if |
remove |
if |
verbose |
if |
depends on option remove
Martin Hecht
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.