Computes element-wise addition of two sparse_numeric objects using the + operator.
# S4 method for class 'sparse_numeric,sparse_numeric'
e1 + e2
Arguments
- e1
A sparse_numeric object.
- e2
A sparse_numeric object of the same length as e1.
Value
A sparse_numeric object representing the element-wise sum.
Examples
x <- new("sparse_numeric", value = c(1, 2), pos = c(2L, 5L), length = 6L)
y <- new("sparse_numeric", value = c(3, 4), pos = c(1L, 5L), length = 6L)
x + y
#> sparse_numeric object of length 6
#> Non-zero elements:
#> pos value
#> 1 1 3
#> 2 2 1
#> 3 5 6