powered by
NA
Set a default value depending on if an object is NA
x %NA% yx %na% yx %!NA% yx %!na% y
x %na% y
x %!NA% y
x %!na% y
For %NA%: y if x is NA; otherwise x
%NA%
y
x
For %!NA%: y if x is not
%!NA%
NA; otherwise x
An object to test
A default value
# 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