[Rd] system() in packages

Robin Hankin r.hankin at noc.soton.ac.uk
Fri Apr 27 16:13:09 CEST 2007


Quite often I need higher precision, or larger numbers,
  than IEEE double precision allows.  One strategy I sometimes
use is to use system() to call pari/gp, which is not constrained by  

[pari/gp is a GPL high-level mathematical programming language
geared towards pure mathematics]

Two of my packages contain lines like the following:

 > system(" echo '1.12^66' | gp -q f",intern=TRUE)

Note the high precision of the answer.

My question is, how to deal with the possibility that pari/gp is not

If the system cannot find gp for some reason, I get:

 > system(" echo '1.12^66' | gp -q f",intern=TRUE)
sh: line 1: gp: command not found

What's the recommended way to handle this eventuality gracefully?  The
functions that do use pari/gp have "pure" R equivalents (but much
slower and less accurate)  so I want users to be able to install the
package without pari/gp.

Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

More information about the R-devel mailing list