An Intorduction to the Interface Between C and R

This manual will be useful for people looking to extend R with the C compiled code. The motivation for using the C interface with R may be bidirectional. For statisticians programming mainly in R, an interface to C provides fast execution of code and better memory management. The C interface also provides the user to access the existing C libraries. Similarly, people programming in C with the help of the R interface to get an access to huge set of mathematical functions implemented in R. It saves the labour of implementing such functions from scratch in C which may be quite cumbersome. In this note, the document illustrates one way to link the C compiled code with R using R function called .C. The use of the .C interface is quite simple and has been explained with the help of examples. The code for examples have been developed in C and various examples shows its execution from R. It is assumed that you have some prior knowledge of C programming and acquaintance with the basics of R. The code discussed in this document should work with any unix installation of R. There is also a PDF manual called Writing R Extensions vailable from the CRAN website. The manual describes other interfaces like .Call and .External which are more complicated to use but certainly more powerful. The following document explains briefly the .C interface.


 Record created 2007-10-01, last modified 2018-03-17

Download fulltext

Rate this document:

Rate this document:
(Not yet reviewed)