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 00 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,] 02 63 53
## [2,] 01 21 4c
## [3,] 19 59 46
## [4,] 1d 5b 62
## [5,] 47 52 23
##
## , , 2
##
## [,1] [,2] [,3]
## [1,] 4a 1e 3f
## [2,] 5e 32 60
## [3,] 64 61 1f
## [4,] 18 4f 39
## [5,] 56 5f 3e
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 raw vectors or arrays. |
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.