Description Usage Arguments Details Value Examples
Winnow out NA
values from a matrix or data.frame, based on
row and column totals.
1 |
x |
matrix or data.frame. |
tol_row, tol_col |
numeric, giving the number of |
order |
logical, should matrix rows and columns be re-ordered by number of
|
The algorithm iteratively removes the most NA
-heavy columns
and/or rows, up to a user-specified tolerance. Useful, for
example, to reduce a huge traits matrix to something that is
NA
-free or can have just a few NA
values to be
later imputed or handled.
Modified dataframe or matrix, with added attributes for original
and new dimensions, and number of NA
that were tolerated
in rows and columns.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ### hypothetical data
set.seed(888)
nr <- 10
nc <- 16
n <- 27 # number of NA to randomly add
x <- matrix(1, nrow=nr, ncol=nc)
na <- cbind(sample(1:nr,n,replace=TRUE),
sample(1:nc,n,replace=TRUE))
x[na] <- NA
x <- data.frame(x)
x
### winnow
(w <- mx_winnow(x, 2, 5)) # tolerate some NA
attributes(w)
(w <- mx_winnow(x, 0, 0)) # tolerate no NA
attributes(w)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.