[Rd] User Input

Thierry Onkelinx thierry.onkelinx at inbo.be
Sun Jul 12 11:58:47 CEST 2015


If you use S4 objects then have a look at ?setValidity

Best regards,

Thierry
Op 11-jul.-2015 04:11 schreef "Glenn Schultz" <glennmschultz at me.com>:

> All,
>
> I have a package BondLab, all variables are passed to the models via Cusip
> objects.
>
> The only variables input by the user are
> settlement date,
> price or yield or spread.
>
> Further price may be passed as 100.125, 100-8 (1/8), or 100-2 (2/64) or
> 100-2+ (5/128).
>
> Once passed these variables must have a steady state (in decimal).  After
> reading the R documentation and Hadley's book I think the way to do this is
> via a class but I can quite get my head around how to do it.  A nominal
> model is:
>
> Analytics <- function(bondid = cusip, tradedate = trade.date, settledate =
> settle.date, price = 100.125){
> BondAnalytics <- BondAnalytics(tradedate = tradedate, settledate =
> settledate, price = price)
> New("BondAnalytics ...)
> }
>
> So, price is an input to a constructor function which calls other
> functions to create the class object BondAnalytics.  If price is an object
> with validity how do I make that part of the function?
>
> If I do make it class how does it function input inherit?  I read John
> Chamber's book but I am not sure... maybe it does not have to be a class
> but something else or is it something like the below:
>
> BondAnalytics <- function(bond.id = "character", tradedate = "character",
> settledate = "character", price = .Object){
> do stuff...}
>
> Advice appreciated,
> -glenn
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list