From thierry.onkelinx at inbo.be  Sun Jul 12 11:58:47 2015
From: thierry.onkelinx at inbo.be (Thierry Onkelinx)
Date: Sun, 12 Jul 2015 11:58:47 +0200
Subject: [Rd] User Input
In-Reply-To: <f55719c5-8eee-4f40-9f7c-028003dfce15@me.com>
References: <f55719c5-8eee-4f40-9f7c-028003dfce15@me.com>
Message-ID: <CAJuCY5xgCTvixbe7Qpb9nr=xkmfPonN6C5ZbtS4CB2qYMnk35g@mail.gmail.com>

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]]



[Rd] User Input
Thierry Onkelinx