Elementwise difference of numeric
or character
arrays.
x %diff% y
numeric
or character
array.
numeric
or character
array.
array
.
Guidotti E (2022). "calculus: High-Dimensional Numerical and Symbolic Calculus in R." Journal of Statistical Software, 104(5), 1-37. doi:10.18637/jss.v104.i05
### vector
x <- c("a+1","b+2")
x %diff% x
#> [1] "0" "0"
### matrix
x <- matrix(letters[1:4], ncol = 2)
x %diff% x
#> [,1] [,2]
#> [1,] "0" "0"
#> [2,] "0" "0"
### array
x <- array(letters[1:12], dim = c(2,2,3))
y <- array(1:12, dim = c(2,2,3))
x %diff% y
#> , , 1
#>
#> [,1] [,2]
#> [1,] "(a) - 1" "(c) - 3"
#> [2,] "(b) - 2" "(d) - 4"
#>
#> , , 2
#>
#> [,1] [,2]
#> [1,] "(e) - 5" "(g) - 7"
#> [2,] "(f) - 6" "(h) - 8"
#>
#> , , 3
#>
#> [,1] [,2]
#> [1,] "(i) - 9" "(k) - 11"
#> [2,] "(j) - 10" "(l) - 12"
#>