Learn R Programming

fixedincome (version 0.0.5)

spotrate-compare-method: SpotRate comparison operations

Description

Comparison operations with SpotRate class SpotRate objects can be compared among themselves or with numeric variables.

Usage

# 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)

Value

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.

Arguments

e1

a SpotRate object or a numeric

e2

a SpotRate object or a numeric

Examples

Run this code

spr <- as.spotrate("0.06 simple actual/365 actual")
spr == 0.06
spr != 0.05
spr > 0.05
spr < 0.1
spr >= 0.05
spr <= 0.1

spr1 <- spotrate(0.06, "simple", "actual/365", "actual")
spr2 <- spotrate(0.02, "simple", "actual/365", "actual")
spr1 == spr2
spr1 != spr2
spr1 > spr2
spr1 < spr2
spr1 >= spr2
spr1 <= spr2

# compare spotrate with different slots
spr2 <- spotrate(0.06, "discrete", "actual/365", "actual")
spr1 == spr2
spr1 != spr2
try(spr1 > spr2)
try(spr1 < spr2)
try(spr1 >= spr2)
try(spr1 <= spr2)

Run the code above in your browser using DataLab