[R] Opening package manual from within R

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Aug 24 08:12:24 CEST 2011


On Tue, 23 Aug 2011, Tyler Rinker wrote:

>
> Simple question but searching rseek did not yield the results I wanted.
>
> Question:  Is there a way to open a help manual for a package from within R.
>
> For instance I would like to type a function in r for the tm package 
> and R would open that PDF as seen here: 
> http://cran.r-project.org/web/packages/tm/tm.pdf
>
> -The vignette function exists for vignettes 
> [vignette("package.name")] so I assume the same exists for manuals.

You assume wrong.  Vignettes PDFs are installed as part of the package 
(and often take minutes to regenerate): the PDF version of the help 
pages (what you seem to call 'the package manual') is not (in 
general).  In many cases what other people (including the author, e.g. 
me for RODBC) call the 'package manual' is a PDF in the doc directory 
(which may or may not be a vignette).

The assumption is that people will use search facilities or the hints 
given by the help titles in help(package="tm") or browse the HTML 
version of the same information (e.g. via help.start).

But you can (provided you have pdflatex etc in your path) generate the 
PDF version of the help pages by

R CMD Rd2pdf /path/to/installed/package

It will even open it in a browser for you (unless you use 
--no-preview).  You could easily encapsulate this in a function by 
e.g.

showPDFmanual <- function(package, lib.loc=NULL)
{
     path <- find.package(package, lib.loc)
     system(paste(shQuote(file.path(R.home("bin"), "R")),
                  "CMD", "Rd2pdf",
                  shQuote(path)))
}

Alternatively *for packages on CRAN only* you can access the version 
on CRAN by browseURL.

> -I do not want library(help="package.name") as this is not detailed enough.
>
> I am running R 2.14.0 beta on a windows 7 machine
> Reproducible code does not seem appropriate in this case.

But accurate 'at a minimum' information (and no HTML) does.  There is 
no such version as '2.14.0 beta', and will not be for a couple of 
months.  If you are running a beta version of R it is old, so please 
update to a released or patched version.   (Also, any version 
calling itself '2.14.0 Under development' is old and needs updating: 
the current R-devel displays no version number.)


> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>

-- 
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