| drop_empty_rc {mclm} | R Documentation | 
Drop empty rows and columns from a matrix
Description
With x a matrix containing frequency counts, drop_empty_rc makes
a copy of x from which the all-zero rows and all-zero columns are removed.
No checks are performed by this function.
Usage
drop_empty_rc(x)
Arguments
x | 
 A matrix, assumed to contain frequency counts.  | 
Details
This is just a convenience function. It is identical to, and implemented as,
x[rowSums(x) > 0, colSums(x) > 0, drop = FALSE].
Value
Matrix, with all-zero rows and columns removed.
Examples
# first example
m <- matrix(nrow = 3, byrow = TRUE,
            dimnames = list(c('r1','r2','r3'),
                           c('c1','c2','c3')),
           c(10, 0, 4,
             0, 0, 0,
             5, 0, 7))
m
m2 <- drop_empty_rc(m)
m2
## second example
m <- matrix(nrow = 3, byrow = TRUE,
           dimnames = list(c('r1','r2','r3'),
                          c('c1','c2','c3')),
           c(0, 0, 4,
             0, 0, 0,
             0, 0, 7))
m
m2 <- drop_empty_rc(m)
m2
## third example
m <- matrix(nrow = 3, byrow = TRUE,
            dimnames = list(c('r1','r2','r3'),
                            c('c1','c2','c3')),
           c(0, 0, 0,
             0, 0, 0,
             0, 0, 0))
m
m2 <- drop_empty_rc(m)
m2 
[Package mclm version 0.2.7 Index]