🔁 replace_void(): Replace Void Values (NA / NULL / "") with a Specified Value
Source:R/replace_void.R
replace_void.Rd
Replace elements in a vector or list that are considered "void" with a user-defined value
.
Void values include NA
, NULL
, and empty strings (""
), each toggleable.
Usage
replace_void(
x,
value = NA,
include_na = TRUE,
include_null = TRUE,
include_empty_str = TRUE
)
Examples
replace_void(c(NA, "", "a"), value = "N/A")
#> [1] "N/A" "N/A" "a"
replace_void(list("A", "", NULL, NA), value = "missing")
#> [[1]]
#> [1] "A"
#>
#> [[2]]
#> [1] "missing"
#>
#> [[3]]
#> [1] "missing"
#>
#> [[4]]
#> [1] "missing"
#>
replace_void(c("", "b"), value = 0, include_empty_str = TRUE)
#> [1] "0" "b"