| drop_empty_rc | R Documentation |
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.
drop_empty_rc(x)
x |
A matrix, assumed to contain frequency counts. |
This is just a convenience function. It is identical to, and implemented as,
x[rowSums(x) > 0, colSums(x) > 0, drop = FALSE].
Matrix, with all-zero rows and columns removed.
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.