replacers: replacemnt and specials

Description Usage Arguments Value See Also Examples

Description

If-this-type-then replace with x. And the other way around; replace with x if this.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
if_na(.x, replacement, missing = NULL)

if_nan(.x, replacement, missing = NULL)

if_inf(.x, replacement, missing = NULL)

if_zero(.x, replacement, missing = NULL)

na_if(.x, condition, replace_na = FALSE)

nan_if(.x, condition, replace_na = FALSE)

inf_if(.x, condition, replace_na = FALSE)

zero_if(.x, condition, replace_na = FALSE)

if_not_na(.x, replacement, missing = NULL)

if_inf(.x, replacement, missing = NULL)

if_nan(.x, replacement, missing = NULL)

if_zero(.x, replacement, missing = NULL)

na_if(.x, condition, replace_na = FALSE)

inf_if(.x, condition, replace_na = FALSE)

nan_if(.x, condition, replace_na = FALSE)

zero_if(.x, condition, replace_na = FALSE)

Arguments

.x

a vector

replacement

a replacement if condition is TRUE

missing

a value that replace missing values in condition.

condition

a predicament

replace_na

if TRUE, missing values in condition will be replaced as well

Value

a vector

See Also

vignette("s"), vignette("hablar")

Examples

1
2
3
4
5
v <- c(1, NA, 2)
if_na(v, 100)

v <- c(999, NA, 2)
zero_if(v, v == 999)

hablar documentation built on March 26, 2020, 7:56 p.m.