[R] Navigate to Index page of a package from R command prompt

Steven McKinney smckinney at bccrc.ca
Thu Jul 23 23:31:43 CEST 2009


> -----Original Message-----
> From: Marc Schwartz [mailto:marc_schwartz at me.com]
> Sent: Thursday, July 23, 2009 2:04 PM
> To: Steven McKinney
> Cc: R-help at r-project.org
> Subject: Re: [R] Navigate to Index page of a package from R command
> prompt
> 
> On Jul 23, 2009, at 3:30 PM, Steven McKinney wrote:
> 
> >
> > Hi all,
> >
> > Is there a way to navigate directly to the "Index" page of help
> > for a package?
> >
> > Here's my connundrum:
> >
> > I download and install package "foo".
> > I don't know what functions are in package "foo",
> > so I can't invoke the help for package "foo" via
> >> ?someFunction
> >
> > help(package = "foo")
> > pops up some non-hyperlinked information page, not
> > package foo's help Index page.
> >
> > If the package author kindly made a "foo" object or function
> > and put that in package "foo", then
> >> ?foo
> > works and yields a help page for package "foo".
> > Now at the bottom of the help page is a hyperlink "Index"
> > and I can click that to navigate to the main help Index page
> > (the page I really want to get to straight from the R
> > command line).
> >
> > I see that the link to "Index" for package "foo" appears always to be
> > (on my Mac)
> >
> file:///Library/Frameworks/R.framework/Resources/library/foo/html/00Ind
> ex.html
> >
> > e.g.
> >
> file:///Library/Frameworks/R.framework/Resources/library/cmprsk/html/00
> Index.html
> >
> >
> file:///Library/Frameworks/R.framework/Resources/library/utils/html/00I
> ndex.html
> >
> > Is there a command from the R listener that can take me directly to
> > this "00Index.html" page of help for package "foo"?
> >
> > something like
> >> help("00Index", package = "utils")
> >
> > (but this does not work)?
> >
> > Any info appreciated
> >
> > Best
> >
> > Steven McKinney
> 
> 
> Steven,
> 
> Once a package has been loaded with 'library(PackageName)', you can
> use .path.package("PackageName") to get the path to the main package
> installation folder and then append the remainder:
> 
> library(survival)
> 
>  > .path.package("survival")
> [1] "/Library/Frameworks/R.framework/Resources/library/survival"
> 
>  > file.path(.path.package("survival"), "html", "00Index.html")
> [1] "/Library/Frameworks/R.framework/Resources/library/survival/html/
> 00Index.html"
> 
> See ?.path.package and ?file.path for more information.
> 
> You can also use .find.package() for unloaded packages and that is
> described on the same help page as .path.package.
> 
> Finally, you can use browseURL() to bring the index file up in your
> browser:
> 
>    browseURL(file.path(.path.package("survival"), "html",
> "00Index.html"))
> 
> HTH,
> 
> Marc Schwartz

Thanks Marc,

Certainly useful information.

I'm just baffled and confused as to why
> ?survival
or
> ?survival:Index
or some such incantation
doesn't just take me right to the index page 
for package "survival" in the default help browser 
for the R session.

Why does it take so much work to get to the 
index page?

> library("survival")
> browseURL(file.path(.path.package("survival"), "html", "00Index.html"))
does conceptually do what I'm looking for, but 
not in the default browser.

I'd like to file a feature request on R-devel if this
is not too naïve of a request.

?survival:Index 
or some such syntax should do what you illustrate
above, but in the default help mechanism.
I don't yet know enough about the ? and ?? machinery
to develop such a capability.  Any ideas?




Best

Steve McKinney




More information about the R-help mailing list