[R] customizing help()
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Tue Apr 4 14:18:53 CEST 2000
On Tue, 4 Apr 2000, Prof Brian D Ripley wrote:
> On Tue, 4 Apr 2000, Kurt Gerber wrote:
>
> > Hi
> > I tried to customize help(), so it starts the compiled html help, and
> > searches in all packages.
> >
> > I wrote the following function:
> >
> > > my.help
> > function(topic){
> > help(topic, package=.packages(all=T), lib.loc=.lib.loc, chmhelp=T)
> > }
> >
> > When I use it with
> >
> > >my.help(help)
> >
> > give the following error:
> >
> > Error in help(topic, package = .packages(all = T), lib.loc = .lib.loc, :
> > No documentation for `topic'
> >
> > I tried also with
> > > my.help
> > function(x){
> > help(x,chmhelp)}
> >
> > with the same result.
> > Only doing help(help) is working. Why my function doesn't work?
>
> Because the first argument of help() is handled specially, to allow
> help(help) or help("help"). my.help(help) passes the help object to help,
> not "help". But my.help("help") will still fail.
>
> I could tell you how to do this, but I do think it is a bad idea, and
> we worked quite hard to do something better in 1.0.0. The problem is that
> those options will find a copy of the help under a given name, and quite
> possibly not help for the object in the packages you have loaded.
Perhaps that was a bit mean, and the general principle at least may be
illuminating. The following should work:
my.help <- function(...)
{
oc <- match.call()
oc[[1]] <- as.name("help")
oc$package <- quote(.packages(all = T))
oc$lib.loc <- quote(.lib.loc)
oc$chmhelp <- TRUE
eval.parent(oc)
}
Martin Maechler mentioned help.search(), which is very useful but does not
pick up the help file(s) directly.
--
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