Sample R package - learn and demo how to access "modern" fortran from R, via Rcpp


This package is the result of a learning experience to explore how to interface R with Fortran(90 or more recent) code. While there is a way to access Fortran code (77 or more recent) from R using the standard R package build process, the manual "R Writing R extension" suggests there are known limitations in mixed language situations (C/C++/F[77|90|etc.]).

The most active area of development for R interop with native libraries is Rcpp. The premise of the present packages is that there is overall more value in taking advantage of Rcpp and the iso_c_binding Fortran-C interoperability module than using the existing R-Fortran interoperability API.

Build instructions

checkout of install_github

Use cases

Technical overview

Creating a package that uses Rcpp

This is a log of what needed done to have a starting point for this package.

Rcpp.package.skeleton(name='Rcppfor', module=TRUE, attributes=TRUE, example_code = TRUE)

Modify the to add the -std:c++0x flag: see



2013-08-30 Well, the build process becomes difficult as soon as one deviates form the usual R package build with source code. I was trying to do all things with the RTools toolchain but it is unclear what is happening with gfortran. Googling opens Pandora's box of partial bits of information. A more pragmatic approach will be to use the Intel VF toolchain and build entirely from visual studio. It does take care of a lot of boilerplate compiler gunk that I find difficult to figure out how to do with gfortran.

jmp75/Rcppfor documentation built on May 19, 2019, 1:55 p.m.