All Projects → dsidavis → RCInterface

dsidavis / RCInterface

Licence: other
Materials for workshop on interface for R and C/C++/compiled code

Programming Languages

E
10 projects
C++
36643 projects - #6 most used programming language
HTML
75241 projects
c
50402 projects - #5 most used programming language
r
7636 projects
Makefile
30231 projects

Working with C/C++ in R

Duncan Temple Lang

Data Science Initiative, UC Davis

This workshop provides an overview and introduction to the ecosystem for interfacing R with compiled code, specifically C and C++. (These cover other compiled languages and also provide the lowest common denominator for all languages, including interpreted languages which can be embedded in R and vice versa)

We discuss

  • the nature of compiled code,
  • the "compilation" process and the importance of understanding the different steps and the make utility for managing dependencies and keeping files updated with respect to changes in others.
  • calling a simple routine working on a primitive R vector
  • using the .Call() interface for more complex and flexible situations, e.g. creating R objects, specifically lists in C code.
  • writing an R package with compiled code
  • interfacing to the 3rd party compiled libraries in C and C++
  • machine-specific compilation flags using pkg-config at installation time
  • configuration for machines with autoconf before compiling.
  • external pointers in R for C/C++ objects (across R function calls)

Slides

Plus

  • Why compiled code is faster than interpreted code
  • Understanding what a compiler does and when.
  • dissambler and machine code
  • the make utiity

CompileSteps

  • Steps in the "compilation" process
    • Pre-processor
    • compiler
    • linker
      • executable
      • shared library
    • loading

dotC

  • .C() interface to simple C routine taking a numeric vector
  • .Call() version

getrusage

  • interface to existing system-level C routine
    • returns a structure
  • .Call()
  • R's C API

Rqpdf

  • C & C++,
  • .Call()
  • pkg-config for compiler and library flags for 3rd party software,
  • external pointers to C/C++ objects in R
    • finalizers and garbage collection
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].