Description Usage Arguments Author(s) Examples
Add two SparseSignals.
1 2 | ## S3 method for class 'SparseSignal'
x + y
|
x |
|
y |
Toby Dylan Hocking
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## adding two non-overlapping 1-segment signals gives a signal with
## 2 segments.
x <- SparseSignal(1, 2, 5.5)
x + SparseSignal(4, 10, 3.8) # 2 rows.
## adding two overlapping 1-segment signals with opposite values
## gives a completely sparse signal with 0 segments.
none <- x + SparseSignal(1, 2, -5.5) # 0 rows.
str(none)
## a more complicated example.
x <- SparseSignal(c(10L, 12L, 14L),
c(11L, 13L, 16L),
c( 1, 2, 3))
y <- SparseSignal(c(10L, 12L, 15L),
c(11L, 13L, 17L),
c( 1, -2, 4))
x + y
## you can also just add vectors, but they need to be length 1 or
## the number of segments.
x + 1000
x + c(1, 200, 3000)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.