[R] Converting Fortran or C++ etc to R

David Duffy davidD at qimr.edu.au
Thu Jan 6 00:27:12 CET 2011


> Murray Jorgensen <maj at stats.waikato.ac.nz> wrote:
>
> I'm going to try my hand at converting some Fortran programs to R. Does
> anyone know of any good articles giving hints at such tasks? I will post
> a selective summary of my gleanings.

Presuming you don't mean .Fortran(), I have gone both ways.  Aside from 
the obvious fact that a single R vectorized command can replace either 
just a loop or an entire Fortran subroutine, I don't have any deep 
insights.  I simply did a line-by-line translation to R, confirmed the 
code still worked, then looked for simple optimizations/refactorings.

If you have a lot of code to port, and are hinting you would like an 
automated tool, I think you are out of luck ;)  There is a Fortran to Lisp 
translator (f2cl), but I think the resulting code will not get you a lot 
closer (it is aimed at compilation).

Cheers, David Duffy.
-- 
| David Duffy (MBBS PhD)                                         ,-_|\
| email: davidD at qimr.edu.au  ph: INT+61+7+3362-0217 fax: -0101  /     *
| Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v



More information about the R-help mailing list