remove_all_NA_rowcols: Trim any rows and/or columns containing all NAs from a matrix...

View source: R/remove_all_NA_rowcols.R

remove_all_NA_rowcolsR Documentation

Trim any rows and/or columns containing all NAs from a matrix or data frame.

Description

Trim any rows and/or columns containing all NAs from a matrix or data frame. Any rows or columns composed entirely of NAs are removed.This is used primarily after reading in a spreadsheet, when excess columns and/or rows may be included due to quirks in the file reading process. It can also remove cases and/or variables with no data.

Usage

remove_all_NA_rowcols(
  x, cols = TRUE, rows = TRUE, interpret_text = TRUE)

Arguments

x

data frame or matrix with rows and/or columns to be removed

cols, rows

logical, whether to trim columns and rows, respectively. By default, both columns and rows are trimmed.

interpret_text

whether to convert text "NA" to NA values. Default behavior is to set values that are read as "NA" to NA before filtering.

Value

an object of the same type as x, potentially with fewer rows and/or columns


mjdufort/miscHelpers documentation built on Feb. 4, 2024, 7:44 p.m.