search for: cmdexp

Displaying 1 result from an estimated 1 matches for "cmdexp".

Did you mean: cmdsexp
2008 Jan 02
1
setting the seed in standalone code using Rlib
...lude <R.h> #include <Rinternals.h> #include <R_ext/Parse.h> #include <Rmath.h> #include <stdio.h> void setSeed(unsigned int seed) { #ifndef MATHLIB_STANDALONE /** * Following the example in Writing R Extensions 5.10 */ char cmd[256]; SEXP cmdSexp; SEXP cmdExp; ParseStatus status; sprintf(cmd, "set.seed(%u)", seed); PROTECT(cmdSexp = allocVector(STRSXP, 1)); SET_STRING_ELT(cmdSexp, 0, mkChar(cmd)); cmdExp = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue)); assert(status == PARSE_OK); eval(VECTOR_ELT(cmdExp, 0), R_G...