[Rd] a question about optim.R and optim.c in R

Sarah Goslee sarah.goslee at gmail.com
Mon Jul 7 23:20:54 CEST 2014


On Mon, Jul 7, 2014 at 4:34 PM, Zhiyuan Dong <zhiyuan.dong at gmail.com> wrote:
> Hi, I am learning R by reading R source code.

That's very brave of you.

You might also try reading some of the documentation and contributed
documentation, like:


Here is one question I have
> about the optim function in R.
> The context : In the optim.R, after all the prep steps, the main function
> call call is made via :
> .External2(C_optim, par, fn1, gr1, method, con, lower, upper).
> So, it seems to me, to follow what is going on from here, that I should
> read the optim function in \src\library\stats\src\optim.c
> where it has this signature :
> SEXP optim(SEXP call, SEXP op, SEXP args, SEXP rho)
> I am not sure I follow here : In the .External2 call, we have 7 parameters
> :  par, fn1, gr1, method, con, lower, upper; This does not seem to match
> the signature of
> SEXP optim(SEXP call, SEXP op, SEXP args, SEXP rho)
> However, it seems (from the source code) that the 7 parameters are somehow
> embedded in the 'args' parameter. I am not sure what is going on...Am I
> missing something?
> Thanks much!!!
> Best,
> Zhiyuan

Sarah Goslee

More information about the R-devel mailing list