Unfortunately for you, this email list is about R (not C), and while the 
Posting Guide indicates that questions discussing how to interface with C 
belong in R-devel, that is not a forum for learning C.

On the plus side,  the data types and macros you are asking questions about are 
highly specific to the implementation of R, so if you spend some time filling 
in your gaps in C on your own or in another forum, you ought be able to get 
answers to your questions on R-devel.

FWIW the R code you show does not appear (to me) to be what calls the C code 
you show... at least not directly. There should be a much more straightforward 
correspondence between the caller and callee than you imply here. 

-- 
Sent from my phone. Please excuse my brevity.

On August 2, 2016 9:06:55 AM PDT, Justin Thong <justinthon...@gmail.com> wrote:
>Hi again I need help
>
>*R-code*
>debug(model.matrix)
>model.matrix(~S)
>
>*model.matrix code*
>ans <- .External2(C_modelmatrix, t, data) #t =terms(object) ,
>data="data
>frame of object"
>
>*modelframe C-code*
>SEXP modelframe(SEXP call, SEXP op, SEXP args, SEXP rho)
>{
>SEXP terms, data, names, variables, varnames, dots, dotnames,
>na_action;
>    SEXP ans, row_names, subset, tmp;
>    char buf[256];
>    int i, j, nr, nc;
>    int nvars, ndots, nactualdots;
>    const void *vmax = vmaxget();
>
>    args = CDR(args);
>    terms = CAR(args); args = CDR(args);
>    row_names = CAR(args); args = CDR(args);
>    variables = CAR(args); args = CDR(args);
>    varnames = CAR(args); args = CDR(args);
>    dots = CAR(args); args = CDR(args);
>    dotnames = CAR(args); args = CDR(args);
>    subset = CAR(args); args = CDR(args);
>    na_action = CAR(args);
>
>. . . .
>
>I am sorry I virtually have no experience in C.
>Can someone explain to me what "args" is at the point when it enters
>the
>function? I know CAR points to the first element of an object, and CDR
>points to the complement of the first element of an object.
>
>Does "args" represent the list of t and data?
>or
>Does "args" represent the thrid argument in .External2 which is data?
>or
>something else
>
>I am guessing this whole process of playing CAR and CDR is just a way
>of
>extracting variables from "args" until everything thing in "args" is
>assigned to.
>
>For instance, if args=(1,2,3,4,5,6) then below correspond in square
>brackets
>
>  args = CDR(args); [(1,2,3,4,5,6)]
>  terms = CAR(args) ;[(1)] args = CDR(args);[(2,3,4,5,6)]
>    row_names = CAR(args);[(2)] args = CDR(args);[(3,4,5,6)]
>    variables = CAR(args);[(3)] args = CDR(args);[(4,5,6)]
>    varnames = CAR(args);[(4)] args = CDR(args);[(5,6)]
>   etc
>
>Is this correct?
>
>I am sorry if I am asking too many questions on C. Please advise if I
>am
>posting inappropriately.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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