Index of /examples/r/examples/call_c

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory   -  
[   ]c_lib.o 2017-11-19 12:32 7.5K 
[TXT]c_lib.c 2017-11-19 12:32 682  
[TXT]R_call_C.R 2017-11-19 12:31 109  

RCS Example of R script call C function

Compile C code:
[scc1 ~] module load R/4.0.2
[scc1 ~] R CMD SHLIB  c_lib.c -o c_lib.so

From R script load the dynamic library:
 dyn.load("c_lib.so")
Execute C function within R script :
result <- .Call("cfunction", a=21.7, b=3.14)

For help email

Research Computing Services: help@scc.bu.edu

Note: RCS example programs are provided "as is" without any warranty of any kind. The user assumes the intire risk of quality, performance, and repair of any defect. You are welcome to copy and modify any of the given examples for your own use.