Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

remove_empty

Remove empty rows and/or columns from a data.frame or matrix.


Description

Removes all rows and/or columns from a data.frame or matrix that are composed entirely of NA values.

Usage

remove_empty(dat, which = c("rows", "cols"), quiet = TRUE)

Arguments

dat

the input data.frame or matrix.

which

one of "rows", "cols", or c("rows", "cols"). Where no value of which is provided, defaults to removing both empty rows and empty columns, declaring the behavior with a printed message.

quiet

Should messages be suppressed (TRUE) or printed (FALSE) indicating the summary of empty columns or rows removed?

Value

Returns the object without its missing rows or columns.

See Also

remove_constant() for removing constant columns.

Other remove functions: remove_constant()

Examples

# not run:
# dat %>% remove_empty("rows")

janitor

Simple Tools for Examining and Cleaning Dirty Data

v2.1.0
MIT + file LICENSE
Authors
Sam Firke [aut, cre], Bill Denney [ctb], Chris Haid [ctb], Ryan Knight [ctb], Malte Grosser [ctb], Jonathan Zadra [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.