Evaluation of nrow()

Jul 31, 2012 at 4:53 PM

Hi,
I define a matrix pay:

pay<-matrix(0,length(PayDates),1,dimnames=list(as.character(PayDates),"payoff"))

and after I use it in payoff function:

payoff <- function(Data, notional)
{
  for (i in 2:3)
  {
    if (all(Data[i,]>=Data[1,]))
    {
      pay[i-1,]<-notional*1.14
      pay[i:nrow(pay),]<-0
      #for ( j in i:nrow(pay) )
      #{
      #  pay[j,]<-0
      #}
      return(pay)
    }
    ...
  }
  ...
  return(pay)
}

All this code is evaluated from .Net and the instruction "pay[i:nrow(pay),]<-0" crashes the program

I had to execute the commented code instead of "pay[i:nrow(pay),]<-0" to get the same results.

Thanks in advanced.
Luca