On Wed, Nov 18, 2015 at 7:35 PM, Glenn Schultz <glennmschu...@me.com> wrote: > All, > > I have the following class with slots as functions. For the analysis of MBS > this is good set-up as it allows for a very clean and modular way of > handling things. My question is really geared to understanding what is > happening in R. > > Below is the function without sato = NULL R CMD throws a warning global > variable not defined. With SATO = NULL I do not get the warning. Why only > sato and not two and ten which are also inputs? > You use sato in the yr15 function even though it is not an argument to the function. Did you forget to add it as an argument to the yr15 function?
> Glenn > > # Bond Lab is a software application for the analysis of # fixed income > securities it provides a suite of applications > # in addition to standard fixed income analysis bond lab provides # for the > specific analysis of structured products residential mortgage backed > securities, # asset backed securities, and commerical mortgage backed > securities > # License GPL3 + File License > # Copyright (C) 2014 Glenn M Schultz, CFA > > #' An S4 class whose slots are functions used to propogate > #' the mortgage rate used to motivate the prepayment model > #' @slot yr30 A function defining the 30-year mortgage rate as a function > #' of the 2- and 10-year swap rate > #' @slot yr15 A function defining the 15-year mortgage rate as a function > #' of the 2- and 10-year swap rate #' @export MortgageRate > > setClass("MortgageRate", > representation( > yr30 = "function", > yr15 = "function")) > > #' A constructor function for the class Mortgage Rate > MortgageRate <- function(){ > sato = NULL > new("MortgageRate", > yr30 = function(two = numeric(), ten = numeric(), sato = numeric()) { > 2.25 + (.06 * two) + (.75 * ten) + sato}, > > yr15 = function(two = numeric(), ten = numeric()){ > 1.75 + (.06 * two) + (.75 * ten) + sato} > )} > ______________________________________________ > R-package-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-package-devel -- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel