You are looking at historical revision 27462 of this page. It may differ significantly from its current revision.

R

R interface for Chicken Scheme

R

[module] R

The R-module provides functions for applying and evaluating R-expressions.

R-missing

[constant] R-missing → (foreign-value R_MissingArg SEXP)

R-constant for missing arguments

(define R-missing (foreign-value "R_MissingArg" SEXP))

R-apply

[procedure] (R-apply f args) → R-pointer

Apply the list of arguments to a function.

f
Function as a string to apply
args
List of arguments to apply to f
(define (R-apply f args)
  (receive
    (named-args unnamed-args)
    (named×unnamed args)
    (let ((named-args
            (map (match-lambda ((name . arg) (cons name (scheme->R arg))))
                 named-args))
          (unnamed-args (map scheme->R unnamed-args))
          (f (R-function f)))
      (debug named-args unnamed-args)
      ((foreign-lambda*
         SEXP
         ((SEXP f) (int error) (scheme-object named) (scheme-object unnamed))
         "int nargs = C_unfix(C_fixnum_plus(C_i_length(named), C_i_length(unnamed)));"
         "SEXP expression = allocVector(LANGSXP, nargs + 1);"
         "SETCAR(expression, (SEXP) f);"
         "SEXP ei = CDR(expression);"
         "while (!C_truep(C_i_nullp(unnamed))) {"
         "  SETCAR(ei, (SEXP) C_c_pointer_or_null(C_i_car(unnamed)));"
         "  unnamed = C_i_cdr(unnamed);"
         "  ei = CDR(ei);"
         "}"
         "while (!C_truep(C_i_nullp(named))) {"
         "  SEXP arg = (SEXP) C_c_pointer_or_null(C_i_cdar(named));"
         "  SET_TAG(arg, install(C_c_string(C_i_caar(named))));"
         "  SETCAR(ei, arg);"
         "  named = C_i_cdr(named);"
         "  ei = CDR(ei);"
         "}"
         "C_return(R_tryEval(expression, R_GlobalEnv, &error));")
       f
       0
       named-args
       unnamed-args))))

R-eval

[procedure] (R-eval f . args) → Scheme-object

Apply the arguments to a function and evaluate the result.

f
Function as a string to apply
args
Arguments to apply to f
(define (R-eval f . args) (R->scheme (R-apply f args)))

About this egg

Author

Peter Danenberg

Colophon

Documented by cock.== R

R interface for Chicken Scheme

R

[module] R

The R-module provides functions for applying and evaluating R-expressions.

R-missing