[Rd] a hack regarding "No documentation ...."

Gabor Grothendieck ggrothendieck at gmail.com
Sun Jun 26 23:15:37 CEST 2005


On 6/26/05, Mike R <mike.rstat at gmail.com> wrote:
> > ?somecharacters
> No documentation for 'somecharacters' in specified packages and libraries:
> you could try 'help.search("somecharacters")'
> >
> 
> I'm looking for some advice.  I'd like to hack my source code
> in such a way that the empty prompt line above is "pre-filled"
> with the suggested command.  In effect, this would make it
> unnecessary to copy-paste (or type)
> help.search("somecharacters")
> 
> If I did not want to execute the suggested command, I would
> Ctrl-c the pre-filled line.
> 
> Alternatively, the hack could implement a query, as in:
> 
> > ?somecharacters
> No documentation for 'somecharacters' in specified packages and libraries:
> you could try:
> 0 - help.search("somecharacters")
> 1 - RSiteSearch("somecharacters")
> 2 -  apropos(somecharacters)
> 3 - etc .....
> <enter> - no action
> 
> .... in which case, typing 0, 1, 2, 3, ... and <enter> would issue
> the corresponding command,  or would pre-fill a command line
> with the corresponding command (which could then be edited).
> 
> Alternatively, the hack could add the recommended commands to
> the command history, in which case I could use the up/down
> arrows to navigate to them.
> 
> I suppose it might be the case that a similar feature is already
> part of R, and that I am just not aware of it.  As a newbie, I spend
> most of my time searching/reading documentation.
> 
> Any comments regarding the possible alternatives that I've
> mentioned, or offers of your own alternatives, would be
> appreciated, as would be suggestions or mini-outlines for
> implementing the hack.
> 

Redefine ?, e.g.

"?" <- function(e1) cat("You entered", substitute(e1), "\n")
?abc

To see the definition of ? that comes with R:
  rm("?")  # remove definition we just made above
  get("?") # look at the definition of function ?



More information about the R-devel mailing list