On Sat, Aug 23, 2008 at 11:46 AM, Douglas Bates <[EMAIL PROTECTED]> wrote:

I don't think it is necessary to go through the agonies of dealing
with the argument list in a .External call., which is what I assume
you are doing. (You haven't given us very much information on how you
are trying to pass the ... argument and such information would be very
helpful.  The readers of this list are quite intelligent but none, as
far as I know, have claimed to be telepathic.)
---

This is the first project for which I've tried to write C code for R.
I am so innocent that I don't even know what I have to explain to get help.

This is to speed up a friend's R package (BB), which is for general-purpose
continuous optimization. So it has to do many of the same things as nlm or
optim: take a function provided by the user, which might have any number of
arguments, and optimize over one (vector) argument.
As with optim, this C code will pass all the arguments for the user-provided
R function back into R, over and over.
I am open to any suggestions about how to do this simply and efficiently.

On Fri, Aug 22, 2008 at 2:16 PM, John Tillinghast <[EMAIL PROTECTED]> wrote:
> > I'm trying to figure this out with "Writing R Extensions" but there's not
> a
> > lot of detail on this issue.
> > I want to write a (very simple really) C external that will be able to
> take
> > "..." as an argument.
> > (It's for optimizing a function that may have several parameters besides
> the
> > ones being optimized.)
>
> > I got the "showArgs" code (from R-exts) to compile and install, but it
> only
> > gives me error messages when I run it. I think I'm supposed to pass it
> > different arguments from what I'm doing, but I have no idea which ones.
>
> > What exactly are CAR, CDR, and CADR anyway? Why did the R development
> team
> > choose this very un-C-like set of commands? They are not explained much
> in
> > R-exts.
>
> Emmanuel has answered that - very engagingly too.  On the train from
> Dortmund to Dusseldorf last week I was describing exactly that
> etymology of the names CAR, CDR, CDDR, ... to my companions but I got
> it wrong.  I had remembered CDR as "contents of the data register" but
> Emmanuel is correct that it was "contents of the decrement register".
>
>
>
> The way that I would go about this is using .Call in something like
>
> .Call("myCfunction", arg1, arg2, dots = list(...), PACKAGE = "myPackage")
>
> Then in your C code you check the length and the names of the dots
> argument and take appropriate action.
>
> An alternative, if you want to use the ... arguments in an R
> expression to be evaluated by your optimizer, is to create an
> environment, assign the elements of list(...) to the appropriate names
> in that environment and pass the environment through .Call to be used
> as the evaluation environment for your R expression.  There is a
> somewhat complicated example of this in the nlmer function in the lme4
> package which you can find at http://lme4.r-forge.r-project.org/.
> However, I don't feel embarrassed about the example being complicated.
>  This is complex stuff and it is not surprising that it isn't
> completely straightforward to accomplish. If you feel that this is
> opaque in R i can hardly wait to see what you think about writing the
> SPSS version.
>

        [[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