# NOT RUN {
cond <- c(TRUE, FALSE)
true <- array(
1:2,
dimnames = list(c("r1", "r2"))
)
false <- rray(
c(3, 4, 5, 6),
dim = c(2, 2),
dim_names = list(c("rr1", "rr2"), c("c1", "c2"))
)
# - All inputs are broadcast to a common
# shape of (2, 2).
# - The first row of the output comes from
# `true`, the second row comes from `false`.
# - The names come from both `true` and `false`.
rray_if_else(cond, true, false)
# }
Run the code above in your browser using DataLab