Comparison operations with SpotRate class
SpotRate
objects can be compared among themselves or with numeric
variables.
# S4 method for SpotRate,SpotRate
>=(e1, e2)
# S4 method for SpotRate,SpotRate
<=(e1, e2)
# S4 method for SpotRate,SpotRate
<(e1, e2)
# S4 method for SpotRate,SpotRate
>(e1, e2)
# S4 method for SpotRate,SpotRate
==(e1, e2)
# S4 method for SpotRate,SpotRate
!=(e1, e2)
# S4 method for SpotRate,numeric
Compare(e1, e2)
# S4 method for numeric,SpotRate
Compare(e1, e2)
a SpotRate
object or a numeric
a SpotRate
object or a numeric
A boolean logical
object.
The comparison with SpotRate
objects only takes all fields
into account.
Comparing SpotRate
against numeric values is equivalent to
coerce the SpotRate
object to numeric execute the operation,
this is a syntax sugar for a shortcut that is commonly applied.
spr <- as.spotrate("0.06 simple actual/365 actual")
spr == 0.06
#> [1] TRUE
spr != 0.05
#> [1] TRUE
spr > 0.05
#> [1] TRUE
spr < 0.1
#> [1] TRUE
spr >= 0.05
#> [1] TRUE
spr <= 0.1
#> [1] TRUE
spr1 <- spotrate(0.06, "simple", "actual/365", "actual")
spr2 <- spotrate(0.02, "simple", "actual/365", "actual")
spr1 == spr2
#> [1] FALSE
spr1 != spr2
#> [1] TRUE
spr1 > spr2
#> [1] TRUE
spr1 < spr2
#> [1] FALSE
spr1 >= spr2
#> [1] TRUE
spr1 <= spr2
#> [1] FALSE
# compare spotrate with different slots
spr2 <- spotrate(0.06, "discrete", "actual/365", "actual")
spr1 == spr2
#> [1] FALSE
spr1 != spr2
#> [1] TRUE
try(spr1 > spr2)
#> Error in stop_if_spotrate_slots_differ(e1, e2, "SpotRate objects have different slots") :
#> SpotRate objects have different slots
try(spr1 < spr2)
#> Error in stop_if_spotrate_slots_differ(e1, e2, "SpotRate objects have different slots") :
#> SpotRate objects have different slots
try(spr1 >= spr2)
#> Error in stop_if_spotrate_slots_differ(e1, e2, "SpotRate objects have different slots") :
#> SpotRate objects have different slots
try(spr1 <= spr2)
#> Error in stop_if_spotrate_slots_differ(e1, e2, "SpotRate objects have different slots") :
#> SpotRate objects have different slots