wilsonfreitas / R-fixedincome

Fixed income tools for R
http://wilsonfreitas.github.io/R-fixedincome/
Other
50 stars 25 forks source link

SpotRateCurve `[` operator raises an error with NA #24

Open wilsonfreitas opened 2 years ago

wilsonfreitas commented 2 years ago
library(fixedincome)

crv <- spotratecurve(
  c(0.1315, 0.1319, 0.1338, 0.1348, 0.1372, 0.1381),
  c(1, 21, 42, 63, 126, 252),
  "discrete", "business/252", "Brazil/ANBIMA",
  refdate = Sys.Date()
)

crv[c(1, NA, 5)]
#> Error in validObject(.Object): invalid class "SpotRateCurve" object: FALSE

This could return NA elements instead of raising an error.