This document discusses extending R with C code. It motivates combining R and C by noting that C code can speed up parts of R programs and allow access to C libraries. It then provides an example of calling a C function from R that returns an integer and examples of passing different R object types to C. It recommends compiling C code into a shared library and loading that into R using dyn.load.
25. $ R CMD SHLIB test.c
? test.so
? R R
? Make?le Makevars
26. R C
dyn.load("test.so")
test <- function(n) {
.Call("test", integer(n))
}
test(24)
Writing R Extensions
http://cran.r-project.org/doc/contrib/manuals-jp/R-exts.jp.pdf
52. ? C R - Seeking for my unique color.
http://d.hatena.ne.jp/syou6162/20090117/1232125870
? Writing R Extensions
http://cran.r-project.org/doc/contrib/manuals-jp/R-exts.jp.pdf