Thank you again for your help.

I updated the parsing at the beginning of the calcProfit function with:

    if (class(IterParam) == "numeric")
      {
        long <- IterParam["long"]
        short <- IterParam["short"]
        investment <- IterParam["investment"]
        stoploss <- IterParam["stoploss"]
        comission <- IterParam["comission"]
        penny <- IterParam["penny"]
        volume <- IterParam["volume"]
        numU <- IterParam["numU"]
        accDefn <- IterParam["accDefn"]
      } else {
          long <- IterParam$long
          short <- IterParam$short
          investment <- IterParam$investment
          stoploss <- IterParam$stoploss
          comission <- IterParam$comission
          penny <- IterParam$penny
          volume <- IterParam$volume
          numU <- IterParam$numU
          accDefn <- IterParam$accDefn
      }

This allows for everything to process as expected for calling it both in the
'for' loop I showed before and as part of 'apply'.
However, I have one other question.

With the 'for' loop, Results is of class data frame.

for (i in 1:length(CombParam$long))
  {
   if(i==1)
     { Results <- calcProfit(CombParam[i,], X, Y)
     } else {
         Results <- rbind(Results, calcProfit(CombParam[i,], X, Y))
       }
  }
-------------------------------------------------------------------------------------------------------
With the 'apply' call, Results2 is of class list.

Results2 <- apply(CombParam, 1, calcProfit, X, Y)

-------------------------------------------------------------------------------------------------------

How can I get convert Results2 from a list to a data frame like Results?

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to