source_function() is the most basic way to source a C function to the R
side. It sources a single C function and exports it on the R side. There
is no need to include the // [[ export() ]] tag when
using source_function(), since only one function will be exported.
source_function(x, includes = NULL, no_remap = TRUE, show = FALSE)
| x |
A block of code containing a single C function to compile. |
|---|---|
| includes |
Extra includes to add manually. By default, |
| no_remap |
Should |
| show |
Should the output of compiling the source code with |
An R function that calls the compiled C code.
code <- " SEXP fn(SEXP x) { return x; } " fn <- source_function(code) fn(1)#> [1] 1