0

This input series works perfectly

 Bond.Valuation (bond.id = bondlab10, principal = 1000, price = 100, 
 settlement.date =  "02-4-2013", trade.date = "1-31-2013")

This throws an error

 Bond.Valuation (bond.id = bondlab10, principal = 1000, price = 100, 
 settlement.date =  "01-5-2013", trade.date = "12-31-2012")

 #Error in Key.Rate.Table[x, 3] = (spotrates("ns", BetaVector, m = Key.Rate.Table[x, 
    : replacement has length zero.

I am trying to use debug tools to step through the code but I am not having much luck. I get the following when I debug

debug at <tmp>#29: Bond.Term.Structure <<- Key.Rate.Analysis(bond.id = bondlab10, 
Rate.Delta = Rate.Delta, BetaVector = BetaVector, principal = principal, 
price = price, cashflow = Bond.CashFlow)

I know the function and the line but I have no idea what is wrong from the messages. Advise on debugging is appreciated. Basically, I have a long settlement here but this will be required for mortgage backed securities.

-Update, I found the problem but not from the debugger. Is there a way to watch R step through each calculation and see values?

IRTFM
  • 258,963
  • 21
  • 364
  • 487
no name
  • 245
  • 2
  • 14
  • I havent personally tried it, but there's been a lot of talk about RStudio's debugging setup. Google can help you there – Ricardo Saporta Oct 18 '13 at 02:09
  • 5
    In general, if you are debugging a function, and it in turn calls another function, simply debug that next one as well. ie, when you were at line `29` above, instead of hitting `c/Enter`, you would write `debug(Key.Rate.Analysis)` You can also use `debugonce` in place of debug – Ricardo Saporta Oct 18 '13 at 02:11

2 Answers2

0

If you are using Windows, Revolution R has good support for step-by-step debugging. It provides a Visual-Studio-style interface to R, with breakpoints and mouseovers on values of variables.

The academic version is free.

Contango
  • 76,540
  • 58
  • 260
  • 305
0

The lastest R-studio has built-in debugger. The community edition is free.

gccering
  • 96
  • 2