library("broadcast")
x <- array(
sample(as.raw(1:100)), c(5, 3, 2)
)
y <- array(
sample(as.raw(1:100)), c(5, 1, 1)
)
cond <- bc.raw(x, y, "!=")
print(cond)
## , , 1
##
## [,1] [,2] [,3]
## [1,] 01 01 01
## [2,] 01 01 00
## [3,] 01 01 01
## [4,] 01 01 01
## [5,] 01 01 01
##
## , , 2
##
## [,1] [,2] [,3]
## [1,] 01 01 01
## [2,] 01 01 01
## [3,] 01 01 01
## [4,] 01 01 01
## [5,] 01 01 01
bc_ifelse(cond, yes = x, no = y)
## , , 1
##
## [,1] [,2] [,3]
## [1,] 62 15 1d
## [2,] 12 1e 42
## [3,] 56 53 36
## [4,] 2a 28 3a
## [5,] 39 03 1a
##
## , , 2
##
## [,1] [,2] [,3]
## [1,] 24 30 4c
## [2,] 4b 1f 35
## [3,] 11 4e 1c
## [4,] 09 26 58
## [5,] 20 2d 5dbc.raw
Broadcasted Operations that Take Raw Arrays and Return Raw Arrays
Description
The bc.raw() function performs broadcasted operations on arrays of type raw, and the return type is always raw.
For bit-wise operations, use bc.bit.
For relational operations with logical (TRUE/FALSE/NA) results, use bc.rel.
Usage
bc.raw(x, y, op, ...)
## S4 method for signature 'ANY'
bc.raw(x, y, op)
Arguments
x, y
|
conformable vectors/arrays of type raw. |
op
|
a single string, giving the operator. Supported operators: ==, !=, <, >, <=, >=, pmin, pmax, diff. The relational operators work the same as in bc.rel, but with the following difference: a TRUE result is replaced with 01, and a FALSE result is replaced with 00. The "diff" operator performs the byte equivalent of abs(x - y).
|
…
|
further arguments passed to or from methods. |
Value
bc.raw() always returns an array of type raw.
For the relational operators, 01 codes for TRUE results, and 00 codes for FALSE results.