[R] Code completion

Prof Brian D Ripley ripley at stats.ox.ac.uk
Sat Feb 17 10:20:15 CET 2001

On Sat, 17 Feb 2001, John Aitchison wrote:

> perhaps this should be directed to r-devel or somesuch, but I thought
> that others might wish to comment on the concept.
> As a fairly new (and very enthusiastic and very appreciative) user of R I
> find myself frequently going to the help files, quite often just for some
> simple help on syntax or function arguments that I vaguely remember ..
> hist(), for instance, has a number of options some of which are to do with
> left and right boundaries of the cells that I sometimes need but not
> often.
> Some form of "code completion" might be of assistance to users like me ..
> not exactly casual users or complete novices, but those who tend to use R
> in bursts perhaps separated by weeks or longer. Code completion is
> implemented in Delphi and perhaps in other languages that have a GUI IDE
> (integrated development environment).. essentially it comes down to the
> IDE prompting you with a function prototype after some delay or on
> pressing some special key (eg ctrl+?)

Yes, that's common on Windows IDEs (and I am pretty sure did not originate
in Delphi). However,

- R does not have an IDE
- R has dynamic scoping, so what function `hist' refers to is
- Most of the arguments in R can be omitted, so very rarely is a full
  function prototype useful.
- You still need a help page to understand the semantics.

> Could something similar be done in R and is it desirable? .. there perhaps
> might be some simple approximation  to code completion achievable by some
> modest changes to the syntax .. eg hist(?) might paste a full function
> prototype like
>      hist(x, breaks, freq = NULL, probability = !freq,
>           include.lowest = TRUE,
>           right = TRUE, col = NULL, border = par("fg"),
>           main = paste("Histogram of" , xname),
>           xlim = range(breaks), ylim = NULL,
>           xlab = xname, ylab,
>           axes = TRUE, plot = TRUE, labels = FALSE,
>           nclass = NULL, ...)
>  into the console window (or perhaps some special edit window)

That you mention `the console window' suggests that you are using a
specific version of R: in general R does not have a console.

On a console system one could envisage, for example, using F1 to bring up
help on the function name just entered.

> well, something to ponder, fwiw.

And after pondering, to contribute code to implement!

It looks to me as if you are using Windows (although you do not say so).
There will be no further Windows-specific development of R unless the user
community contributes it.  Remember R is a volunteer project, and (a)
none of the core developers use Windows for their own work and (b) we do
use R regularly.  Bells and whistles are what you pay money for in
commercial systems (like Delphi).

You might want to take a look at the ESS package for Emacs (runs on Windows
too) which is the nearest there is to an IDE for R.

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