R: Replace missing values

op-na-default {rlang} | R Documentation

## Replace missing values

### Description

This infix function is similar to `%||%` but is vectorised and provides a default value for missing elements. It is faster than using `base::ifelse()` and does not perform type conversions.

### Usage

    x %|% y

### Arguments

`x, y` | `y` for elements of `x` that are NA; otherwise, `x`.

### See Also

op-null-default

### Examples

    c("a", "b", NA, "c") %|% "default"

[Package rlang version 0.2.2 Index]