| void | R Documentation |
A comprehensive suite of functions for detecting, removing, and managing "void" values (NA, NULL, and empty strings) in R objects.
is_void(x, include_na = TRUE, include_null = TRUE, include_empty_str = TRUE)
any_void(x, include_na = TRUE, include_null = TRUE, include_empty_str = TRUE)
drop_void(x, include_na = TRUE, include_null = TRUE, include_empty_str = TRUE)
replace_void(
x,
value = NA,
include_na = TRUE,
include_null = TRUE,
include_empty_str = TRUE
)
cols_with_void(
data,
include_na = TRUE,
include_null = TRUE,
include_empty_str = TRUE,
return_names = TRUE
)
rows_with_void(
data,
include_na = TRUE,
include_null = TRUE,
include_empty_str = TRUE
)
x |
A vector or list. |
include_na |
Logical. Detect |
include_null |
Logical. Detect |
include_empty_str |
Logical. Detect empty strings |
value |
The replacement value to use for voids. Default: |
data |
A data.frame or tibble. |
return_names |
Logical. If TRUE (default), return column names; else logical vector. |
The void utilities family consists of:
is_void: Core detection function returning logical vector
any_void: Check if any void value exists
drop_void: Remove void values from vectors/lists
replace_void: Replace void values with custom values
cols_with_void: Detect columns containing void values
rows_with_void: Detect rows containing void values
All functions support customizable void detection through three parameters:
include_na: Consider NA as void (default: TRUE)
include_null: Consider NULL as void (default: TRUE)
include_empty_str: Consider "" as void (default: TRUE)
A logical vector indicating which elements are void.
If x is NULL, returns a single TRUE (if include_null=TRUE) or FALSE.
If x is an empty vector, returns logical(0).
If x is a list, evaluates each element recursively and returns a flattened logical vector.
For atomic vectors, returns a logical vector of the same length.
A single logical value:
TRUE if any void values are present.
FALSE otherwise.
For NULL input, returns TRUE if include_null = TRUE, else FALSE.
A cleaned vector or list of the same type as input, with void values removed.
A cleaned vector or list with void values replaced.
A character vector (column names) or logical vector indicating void presence per column.
A logical vector of length nrow(data) indicating whether each row
contains at least one void value.
Check for Null / NA / Blank ("") Values
Determine whether input values are considered "void": NULL, NA, or "".
Each condition is controlled by a dedicated argument.
Check if Any Value is Void (NA / NULL / "")
Test whether any element in a vector or list is considered "void".
Void values include NA, NULL, and empty strings (""), and
you can customize which ones to consider.
Remove Void Values from a Vector or List
Removes elements from a vector or list that are considered "void":
NA, NULL, and empty strings (""). Each can be toggled via parameters.
Replace void values (NA / NULL / "")
Replace elements in a vector or list considered "void" with a specified value.
Void values include NA, NULL, and empty strings "" (toggle via flags).
Detect Columns Containing Void Values
Scan a data.frame or tibble and identify columns that contain any "void" values.
Void values include NA, NULL, and "", which can be toggled via parameters.
Detect rows containing void values (NA / NULL / "")
Scan a data.frame or tibble and identify rows that contain any "void" values.
Void values include NA, NULL, and empty strings "" (toggle via flags).
is_void(c(NA, "", "text")) # TRUE TRUE FALSE
is_void(list(NA, "", NULL, "a")) # TRUE TRUE TRUE FALSE
is_void("NA", include_na = FALSE) # FALSE
is_void(NULL) # TRUE
any_void(c("a", "", NA)) # TRUE
any_void(list("x", NULL, "y")) # TRUE
any_void(c("a", "b", "c")) # FALSE
any_void(NULL) # TRUE
any_void("", include_empty_str = FALSE) # FALSE
drop_void(c("apple", "", NA, "banana"))
drop_void(list("A", NA, "", NULL, "B"))
drop_void(c("", NA), include_na = FALSE)
replace_void(c(NA, "", "a"), value = "N/A")
replace_void(list("A", "", NULL, NA), value = "missing")
replace_void(c("", "b"), value = 0, include_empty_str = TRUE)
df <- data.frame(name = c("A", "", "C"), score = c(1, NA, 3), id = 1:3)
cols_with_void(df)
cols_with_void(df, return_names = FALSE)
cols_with_void(df, include_na = FALSE)
df <- data.frame(id = 1:3, name = c("A", "", "C"), score = c(10, NA, 20))
rows_with_void(df)
df[rows_with_void(df), ]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.