library("broadcast")
<- array(
x sample(as.raw(1:100)), c(5, 3, 2)
)<- array(
y sample(as.raw(1:100)), c(5, 1, 1)
)
<- bc.raw(x, y, "!=")
cond print(cond)
## , , 1
##
## [,1] [,2] [,3]
## [1,] 01 01 01
## [2,] 01 01 01
## [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,] 31 37 32
## [2,] 59 1b 4c
## [3,] 1e 57 2c
## [4,] 64 58 3b
## [5,] 15 52 5c
##
## , , 2
##
## [,1] [,2] [,3]
## [1,] 3a 18 02
## [2,] 61 24 63
## [3,] 45 12 28
## [4,] 4e 33 2b
## [5,] 16 1c 25
bc.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.