| rray_if_else | R Documentation |
rray_if_else() selects values from true and false using a logical
condition. When an element of condition is NA, it selects from
missing, or returns a missing value if missing is NULL.
All supplied inputs are broadcast to common dimensions. The common output
type comes from true, false, and missing.
rray_if_else(condition, true, false, ..., missing = NULL, dimensions = NULL)
condition |
A logical array. |
true |
Values to use where |
false |
Values to use where |
... |
These dots are for future extensions and must be empty. |
missing |
Values to use where |
dimensions |
An optional integer vector of output dimensions. When
supplied, every input must broadcast to these dimensions. Use
|
An array with the common dimensions of the inputs, or dimensions when
supplied. Its type comes from true, false, and missing.
Names are dropped.
x <- array(1:12, c(3L, 4L))
x[1, 1] <- NA_integer_
y <- array(101:104, c(1L, 4L))
rray_if_else(x > 5L, x, y, missing = 0L)
condition <- array(c(TRUE, FALSE), c(2L, 1L))
true <- array(1:6, c(2L, 3L))
false <- array(11:16, c(2L, 3L))
rray_if_else(condition, true, false)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.