[R] use dyn.load to redefine R internal fns?

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Aug 26 11:59:22 CEST 1999

> Date: Thu, 26 Aug 1999 10:41:49 +0200 (MET DST)
> From: Joerg Kindermann <Joerg.Kindermann at gmd.de>
> I would like to redefine some R print functions  (Rprintf for example) so
> that they don't print to stdout, but save the output in a global string
> array. I can compile and link my definition of Rprintf into a library and
> load it with dyn.load. I don't get an error message, but afterwards the
> original function is still valid, my new version isn't executed.
> Is there a way to change R internal functions with dyn.load?

Not that I am going to tell you, as it would be an enormous security
loophole if you could replace internal calls that way. But if you can
build from source, you can do anything you want in your version.
(AFAIK, the symbol Rprintf in the system code will be resolved at the
link at the end of the build, so you need your version available then.)

You haven't told us what platform you are using. But Rprintf does not
just `print to stdout', as if it did the GUI versions of R could not work.
What it actually does is print to R_Outputfile if that is open (for use
with sink), otherwise call R_WriteConsole. It sounds as if you want 
to do is to write an alternative front-end with a different
R_WriteConsole.  That is quite easy to do on Unix, very easy on Windows
in the next version as there is extensive support for multiple

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list