[R] R command line: need intelligent command history recall?

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Feb 4 10:20:45 CET 2006


I guess you are using Windows, as you do not tell us.

History search facilities are available in Rterm.exe, and also in readline 
as used in the interface on Unix-alikes.  Many people use Emacs+ESS.  (In 
all cases I think the search mode is slicker than you describe for 
Matlab.) And RGui has another mechanism (read on) that is more suited to a 
GUI.

If you would like a history search in RGui.exe, please contribute the code 
to do so.  R is a volunteer project, and this was deliberately not 
implemented as no Windows user expressed an interest.

I think you will find `the productivity' is in using a higher-level 
language than C.  R does have a line-by-line debugger (called debug, so 
not hard to find).  If you want to set breakpoints etc, see package 
`debug' on CRAN.  And the `Writing R Extensions' manual in the R-devel 
version of R (to become 2.3.0) has a chapter on `Debugging'.

I teach 50 or so people to use R/S a year.  They end up with different 
patterns of working.  Some use script windows all the time, some use 
Emacs+ESS, some use a Linux command line/Rterm.exe.  I believe it is a 
mistake to think that `one size fits all'.

On Sat, 4 Feb 2006, Michael wrote:

> Hi all,
>
> I am not sure if this feature exists in the R-console command line prompt:
>
> In Matlab, if I want to enter a command which is similar to what I have
> entered before,
>
> I can enter a few prefix, then press "->", the previous command that matches
> with this prefix will then appear on this command line, and it saves a lot
> of our time.
>
> For example:
>
>> abline(lm(new~old))
>> cor(new, old)
> ...
> ...
> ... many lines entered
> ...
> ...
>
> now I want to reuse "abline(lm(new~old))",

Try history().  This pops up a window from which you can submit one or 
more command lines (or parts of lines).

> R-console provides "->" functionality to recall old commands, but it trace
> back one by one, it is slow if "abline" is way back, say 50 lines above my
> current command line... it is too slow.
>
> In Matlab, I just need to enter "ab", then press "->", if there is no other
> "ab******" between the "abline" and my current command line, then the
> console will intelligently recall "abline" back to me... Very convinient.
>
> Does this feature exist in R?

Yes.

> Any other good Integrated Developement Environment for R?
>
> Perhaps R users are mathematicians and statisticians; but as a software
> engineer myself, I found a Visual C++-like integrated developement
> environment is really efficient and time-saving. It and Borland C++ Builder
> basically sets standard for modern UI design for programming IDEs.

That is a matter of opinion.  If you want us to accept your opinion, you 
need to give your credentials, and you haven't even told us your name and 
affiliation.

> To be a good IDE, it really needs to have an embedded inline debugger. I've
> asked a statistician, he said he never debugged using a break-point,
> line-by-line execution debugger -- I cannot imagine this. Where is the
> productivity?
>
> I've used Tinn-R. Frankly it is quite creative. It solved the line-by-line
> execution problem by copying the line and pasted it to R-console
> automatically. But a lot of times clipboard generates error. And often times
> the copy and paste within Tinn editor itself are problemetic. For example, I
> have been never able to select a portion of a line. When I paste a
> paragraph, it always erases the current line and the following lines,
> instead of inserting, ...  and if I want to select one line, it always
> select two lines for me... etc.
>
> Anyway, I hope there is IDEs that are better than Tinn-R.
>
> Thanks a lot!
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list