Learn R Programming

evanverse (version 0.3.7)

drop_void: drop_void: Remove Void Values from a Vector or List

Description

Removes elements from a vector or list that are considered "void": NA, NULL, and empty strings (`"""). Each can be toggled via parameters.

Usage

drop_void(x, include_na = TRUE, include_null = TRUE, include_empty_str = TRUE)

Value

A cleaned vector or list of the same type as input, with void values removed.

Arguments

x

A vector or list.

include_na

Logical. Remove NA if TRUE. Default: TRUE.

include_null

Logical. Remove NULL if TRUE. Default: TRUE.

include_empty_str

Logical. Remove "" if TRUE. Default: TRUE.

Examples

Run this code
drop_void(c("apple", "", NA, "banana"))
drop_void(list("A", NA, "", NULL, "B"))
drop_void(c("", NA), include_na = FALSE)

Run the code above in your browser using DataLab