Description Usage Arguments Details Value Examples
These functions provide the implementations for their underlying infix
operators (i.e. rray_add()
powers +
). All operators apply broadcasting
to their input.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | x %b+% y
rray_add(x, y)
x %b-% y
rray_subtract(x, y)
x %b*% y
rray_multiply(x, y)
x %b/% y
rray_divide(x, y)
x %b^% y
rray_pow(x, y)
rray_identity(x)
rray_opposite(x)
|
x, y |
A pair of vectors. |
In case you want to apply arithmetic operations with broadcasting to
purely base R objects using infix operators, custom infix functions have
been exported, such as %b+%
, which will perform addition with
broadcasting no matter what type the input is.
The value of the arithmetic operation, with dimensions identical to the common dimensions of the input.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | library(magrittr)
x <- rray(1:8, c(2, 2, 2)) %>%
rray_set_row_names(c("r1", "r2")) %>%
rray_set_col_names(c("c1", "c2"))
y <- matrix(1:2, nrow = 1)
# All arithmetic functions are applied with broadcasting
rray_add(x, y)
# And the power `+` when any underlying input
# is an rray
x + y
# If you happen to only have base R matrices/arrays
# you can use `rray_add()` or `%b+%` to get the
# broadcasting behavior
rray_add(y, matrix(1:2))
y %b+% matrix(1:2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.