search for: cddr

Displaying 13 results from an estimated 13 matches for "cddr".

Did you mean: addr
2008 Mar 29
0
"Writing R Extensions": bad example with CAR / CDR as lvalues (PR#11054)
...; PROTECT( call = Rf_allocList( 3 ) ); SET_TYPEOF( call, LANGSXP ); SETCAR( call, install( "rm" ) ); SETCAR( CDR(call), allocVector( STRSXP, 1 ) ); SET_STRING_ELT( CAR( CDR(call) ), 0, mkChar( s ) ); SET_TAG( CDR(call), install("list") ); SETCAR( CDDR(call), ev ); SET_TAG( CDDR(call), install("envir") ); eval( call, R_GlobalEnv ); UNPROTECT( 1 );
2014 Jun 25
1
Need help on calling Head from C
Hi , I am trying to call head function from C . My doubt is with the parameter n,how to pass it . PROTECT(dfm=lang3(install("data.frame"),df,ScalarLogical(FALSE))); SET_TAG(CDDR(dfm), install("stringsAsFactors")) ; SEXP res = PROTECT(eval(dfm,R_GlobalEnv)); PROTECT(head=lang3(install("head"),res,ScalarInteger(1))); head = PROTECT(eval(head,R_GlobalEnv)); I tried the above following , it seemed to be not working . Can you please help. Thanks [[alte...
2020 Jun 30
3
Build a R call at C level
...gt; call_to_sum <- inline::cfunction( > language = "C", > sig = c(x = "SEXP"), body = " > > SEXP e = PROTECT(lang2(install(\"sum\"), x)); > SEXP r_true = PROTECT(CONS(ScalarLogical(1), R_NilValue)); > SETCDR(CDR(e), r_true); > SET_TAG(CDDR(e), install(\"na.rm\")); > Rf_PrintValue(e); > SEXP ans = PROTECT(eval(e, R_GlobalEnv)); > UNPROTECT(3); > return ans; > > ") > > call_to_sum(c(1L,NA,3L)) > > On Tue, Jun 30, 2020 at 10:08 AM Morgan Morgan > <morgan.emailbox at gmail.com> wrote:...
2014 Apr 03
1
question regarding lang2 command in C
Hi , I am asking too many questions , sorry for that . I am creating a data frame in C itself , reading a table . The data frame calling code looks like this ====================================== *PROTECT(dfm=lang2(install("data.frame"),df));* *SEXP res = PROTECT(eval(dfm,R_GlobalEnv));* UNPROTECT(2); return res; ================================== It works fine , now the problem
2008 Mar 31
1
(PR#11054) "Writing R Extensions": bad example with CAR /
...ocList( 3 ) ); > SET_TYPEOF( call, LANGSXP ); > > SETCAR( call, install( "rm" ) ); > > SETCAR( CDR(call), allocVector( STRSXP, 1 ) ); > SET_STRING_ELT( CAR( CDR(call) ), 0, mkChar( s ) ); > SET_TAG( CDR(call), install("list") ); > > SETCAR( CDDR(call), ev ); > SET_TAG( CDDR(call), install("envir") ); > > eval( call, R_GlobalEnv ); > UNPROTECT( 1 ); > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > -- Brian...
2020 Jun 30
2
Build a R call at C level
Hi All, I was reading the R extension manual section 5.11 ( Evaluating R expression from C) and I tried to build a simple call to the sum function. Please see below. call_to_sum <- inline::cfunction( language = "C", sig = c(x = "SEXP"), body = " SEXP e = PROTECT(lang2(install(\"sum\"), x)); SEXP ans = PROTECT(eval(e, R_GlobalEnv)); UNPROTECT(2); return
2019 Nov 04
2
Questions on the R C API
Hi All, I have some questions regarding the R C API. Let's assume I have a function which is defined as follows: R file: myfunc <- function(a, b, ...) .External(Cfun, a, b, ...) C file: SEXP Cfun(SEXP args) { args = CDR(args); SEXP a = CAR(args); args = CDR(args); SEXP b = CAR(args); args = CDR(args); /* continue to do something with remaining arguments in "..."
2020 Jun 30
0
Build a R call at C level
...re if that is the best way, but works. call_to_sum <- inline::cfunction( language = "C", sig = c(x = "SEXP"), body = " SEXP e = PROTECT(lang2(install(\"sum\"), x)); SEXP r_true = PROTECT(CONS(ScalarLogical(1), R_NilValue)); SETCDR(CDR(e), r_true); SET_TAG(CDDR(e), install(\"na.rm\")); Rf_PrintValue(e); SEXP ans = PROTECT(eval(e, R_GlobalEnv)); UNPROTECT(3); return ans; ") call_to_sum(c(1L,NA,3L)) On Tue, Jun 30, 2020 at 10:08 AM Morgan Morgan <morgan.emailbox at gmail.com> wrote: > > Hi All, > > I was reading the R ext...
2020 Jun 30
0
Build a R call at C level
...tion( > > language = "C", > > sig = c(x = "SEXP"), body = " > > > > SEXP e = PROTECT(lang2(install(\"sum\"), x)); > > SEXP r_true = PROTECT(CONS(ScalarLogical(1), R_NilValue)); > > SETCDR(CDR(e), r_true); > > SET_TAG(CDDR(e), install(\"na.rm\")); > > Rf_PrintValue(e); > > SEXP ans = PROTECT(eval(e, R_GlobalEnv)); > > UNPROTECT(3); > > return ans; > > > > ") > > > > call_to_sum(c(1L,NA,3L)) > > > > On Tue, Jun 30, 2020 at 10:08 AM Morgan Morga...
2019 Nov 04
0
Questions on the R C API
...t. As for as I know, R defines a set of convenient functions for you to access a limited number of elements. See below ``` #define CAR(e) ((e)->u.listsxp.carval) #define CDR(e) ((e)->u.listsxp.cdrval) #define CAAR(e) CAR(CAR(e)) #define CDAR(e) CDR(CAR(e)) #define CADR(e) CAR(CDR(e)) #define CDDR(e) CDR(CDR(e)) #define CDDDR(e) CDR(CDR(CDR(e))) #define CADDR(e) CAR(CDR(CDR(e))) #define CADDDR(e) CAR(CDR(CDR(CDR(e)))) #define CAD4R(e) CAR(CDR(CDR(CDR(CDR(e))))) ``` You can use them to get first a few arguments from a pairlist. Another solution would be converting the pairlist into a list so...
2010 Nov 12
0
Installing R+Emacs+MikTeX editor on a USB drive
...file in it. It should contain the following lines: (defvar usb-site-lisp-dir (expand-file-name "site-lisp" usb-home-dir)) (setq load-path (cons usb-site-lisp-dir load-path)) (let ((dir (delete nil (mapcar (lambda (f) (unless (string-match "\\.elc?\\'" f) f)) (cddr (directory-files usb-site-lisp-dir t)))))) (setq load-path (append dir load-path))) ;;portable emacs will know about portable R (setq inferior-R-program-name (concat usb-home-dir "../R/R-2.11.1/bin/Rterm.exe")) ;; no command history needed, no need to save workplace at the end of R ses...
2019 Nov 05
1
Questions on the R C API
...enient functions for you to access a limited number of elements. See > below > > ``` > #define CAR(e) ((e)->u.listsxp.carval) > #define CDR(e) ((e)->u.listsxp.cdrval) > #define CAAR(e) CAR(CAR(e)) > #define CDAR(e) CDR(CAR(e)) > #define CADR(e) CAR(CDR(e)) > #define CDDR(e) CDR(CDR(e)) > #define CDDDR(e) CDR(CDR(CDR(e))) > #define CADDR(e) CAR(CDR(CDR(e))) > #define CADDDR(e) CAR(CDR(CDR(CDR(e)))) > #define CAD4R(e) CAR(CDR(CDR(CDR(CDR(e))))) > ``` > > You can use them to get first a few arguments from a pairlist. Another > solution would be...
2008 Aug 22
2
Sending "..." to a C external
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