rm_empty | R Documentation |
Remove empty elements from a vector, list, matrix, data.frame
rm_empty(x, na.rm = FALSE, margin = NULL)
## S4 method for signature 'matrix'
rm_empty(x, na.rm = FALSE, margin = c(1L, 2L))
## S4 method for signature 'data.frame'
rm_empty(x, na.rm = FALSE, margin = 2L)
## S4 method for signature 'data.table'
rm_empty(x, na.rm = FALSE, margin = 2L)
## S4 method for signature 'missing'
rm_empty(x, na.rm = FALSE, margin = 2L)
x |
An R object |
na.rm |
(logical) If |
margin |
(numeric | integer) For data.frame and matrix, to remove the empty rows (1L) or empty columns (2L). Default: 2L. |
x
without the empty elements
## Not run:
x <- list(0, NULL, "a", NA, "")
rm_empty(x)
rm_empty(x, na.rm = TRUE)
df <- data.frame(a = c(1L, 2L, NA_integer_, 4L, 5L), b = c("a", "b", "", "d", "e"), c = NA)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.