[R] Functions ,Optim, & Dataframe

Michael Papenfus mmpapenf at wisc.edu
Mon Jul 31 19:32:47 CEST 2006

I think I need to clarify a little further on my original question.

I have the following two rows of data:
  d1 d2 p1 p2
1 3 6 0.55 0.85
2 5 10 0.05 0.35

I need to optimize the following function using  optim for each row in mydat
fr<-function(x) {
x0<-c(1,1)    # starting values for two unknown parameters

In my defined function fr, (d1 d2 p1 p2) are known values which I need 
to read in from my dataframe and u & v are the TWO unknown parameters.  
I want to solve this equation for each row of my dataframe.

I can get this to work when I manually plug in the known values (d1 d2 
p1 p2).  However, I would like to apply this to each row in my dataframe 
where the known values are automatically passed to my function which 
then is sent to optim which solves for the two unknown parameters for 
each row in the dataframe.

thanks again,


mmpapenf at wisc.edu

More information about the R-help mailing list