[R] Functions ,Optim, & Dataframe

Michael Papenfus mmpapenf at wisc.edu
Mon Jul 31 07:46:50 CEST 2006

I have defined the following function:

fr<-function(x) {
which I then solve using optim

 > y$par
[1] 1.0029771 0.7610545
This works fine.

Now I want to use these two steps on a dataframe:
 > mydat
  d1 d2   p1   p2
1  3  6 0.55 0.85
2  5 10 0.05 0.35

where for each row in mydat, I append the two parameter resulting from 
optim into mydat.
I want to do this for a larger dataset but thought I would start with a 
simple two row dataframe.

I have tried this with loops and the apply function, but seem to be 
getting nowhere.
Thanks for any input.
mmpapenf at wisc.edu

More information about the R-help mailing list