Description Usage Arguments Value Examples
source_code()
will parse through x
looking for functions tagged with
// [[ export() ]]
and will compile the code block and export those
functions to the R side.
1 | source_code(x, includes = NULL, no_remap = TRUE, show = FALSE)
|
x |
A block of C code to compile. |
includes |
Extra includes to add manually. By default, |
no_remap |
Should |
show |
Should the output of compiling the source code with |
A named list containing the functions specified for export.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | code <- "
static SEXP helper(SEXP x) {
return x;
}
// [[ export() ]]
SEXP fn1(SEXP x) {
return helper(x);
}
// [[ export() ]]
SEXP fn2(SEXP x, SEXP y) {
double result = REAL(x)[0] + REAL(y)[0];
return Rf_ScalarReal(result);
}
"
sourced <- source_code(code)
sourced$fn1(1)
sourced$fn2(1, 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.