Created
November 24, 2020 23:35
-
-
Save arraytools/7d32d92fee88ffc029365d178bc09e75 to your computer and use it in GitHub Desktop.
An example from Bioconductor workshop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Rembedded.h> | |
#include <Rdefines.h> | |
static void doSplinesExample(); | |
int | |
main(int argc, char *argv[]) | |
{ | |
Rf_initEmbeddedR(argc, argv); | |
doSplinesExample(); | |
Rf_endEmbeddedR(0); | |
return 0; | |
} | |
static void | |
doSplinesExample() | |
{ | |
SEXP e, result; | |
int errorOccurred; | |
// create and evaluate 'library(splines)' | |
PROTECT(e = lang2(install("library"), mkString("splines"))); | |
R_tryEval(e, R_GlobalEnv, &errorOccurred); | |
if (errorOccurred) { | |
// handle error | |
} | |
UNPROTECT(1); | |
// 'options(FALSE)' ... | |
PROTECT(e = lang2(install("options"), ScalarLogical(0))); | |
// ... modified to 'options(example.ask=FALSE)' (this is obscure) | |
SET_TAG(CDR(e), install("example.ask")); | |
R_tryEval(e, R_GlobalEnv, NULL); | |
UNPROTECT(1); | |
// 'example("ns")' | |
PROTECT(e = lang2(install("example"), mkString("ns"))); | |
R_tryEval(e, R_GlobalEnv, &errorOccurred); | |
UNPROTECT(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment