na_swap: Swap out/for missing values

Description Usage Arguments Value Examples

Description

Swap out/for missing values

Usage

1
2
3
4
5
6
7
8
9
zero_na(x)

na_zero(x)

null_na(x, unlist = FALSE, ...)

empty_na(x, unlist = FALSE, ...)

to_na(x, values)

Arguments

x

a vector.

unlist

logical, whether to unlist the result.

...

further arguments to pass to unlist().

Value

For zero_na, 0 values replaced with NA.

For na_zero, NA values replaced with 0.

For null_na, NULL values replaced with NA.

For empty_na, empty strings ("") replaced with NA.

For to_na, arbitrary values replaced with NA.

Examples

1
2
3
4
5
6
7
8
x <- sample(c(0:5, NA), 10, replace = TRUE)
rbind(x,
      zero_na = zero_na(x),
      na_zero = na_zero(x)
      )

y <- list(1, 0, NULL, 1, 0)
null_na(y)

coletl/coler documentation built on May 12, 2021, 9:44 p.m.