Learn R Programming

SeuratObject (version 5.0.2)

set-if-na: Set If or If Not NA

Description

Set a default value depending on if an object is NA

Usage

x %NA% y

x %na% y

x %!NA% y

x %!na% y

Value

For %NA%: y if x is NA; otherwise x

For %!NA%: y if x is not

NA; otherwise x

Arguments

x

An object to test

y

A default value

Examples

Run this code
# Set if NA
1 %NA% 2
NA %NA% 2

# Set if *not* NA
1 %!NA% 2
NA %!NA% 2

Run the code above in your browser using DataLab