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/00Index.html

e.g.
file:///Library/Frameworks/R.framework/Resources/library/cmprsk/html/00Index.html

file:///Library/Frameworks/R.framework/Resources/library/utils/html/00Index.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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to