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

empty_cols

Return or remove variables or observations that are completely missing


Description

These functions check which rows or columns of a data frame completely contain missing values, i.e. which observations or variables completely have missing values, and either 1) returns their indices; or 2) removes them from the data frame.

Usage

empty_cols(x)

empty_rows(x)

remove_empty_cols(x)

remove_empty_rows(x)

Arguments

x

A data frame.

Value

For empty_cols and empty_rows, a numeric (named) vector with row or column indices of those variables that completely have missing values.

For remove_empty_cols and remove_empty_rows, a data frame with "empty" columns or rows removed.

Examples

tmp <- data.frame(a = c(1, 2, 3, NA, 5),
                  b = c(1, NA, 3, NA , 5),
                  c = c(NA, NA, NA, NA, NA),
                  d = c(1, NA, 3, NA, 5))

tmp

empty_cols(tmp)
empty_rows(tmp)

remove_empty_cols(tmp)
remove_empty_rows(tmp)

sjmisc

Data and Variable Transformation Functions

v2.8.6
GPL-3
Authors
Daniel Lüdecke [aut, cre] (<https://orcid.org/0000-0002-8895-3206>), Iago Giné-Vázquez [ctb], Alexander Bartel [ctb] (<https://orcid.org/0000-0002-1280-6138>)
Initial release

We don't support your browser anymore

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