[R] [Rd] How to link to vignette from .Rd file

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Nov 8 15:36:48 CET 2006


This looks very like the print method for vignettes. This is

> utils:::print.vignette
function (x, ...)
{
     if (length(x$pdf)) {
         if (.Platform$OS.type == "windows")
             shell.exec(x$pdf)
         else system(paste(getOption("pdfviewer"), x$pdf, "&"))
     }
     else {
         warning(gettextf("vignette '%s' has no PDF", x$topic),
             call. = FALSE, domain = NA)
     }
}

which is more elegant in several ways than those solutions earlier in this 
thread (the one below does not even work on Win9x or if CMD.exe is not in 
the path).


On Wed, 8 Nov 2006, Antonio, Fabio Di Narzo wrote:

> 2006/11/8, Agner Fog <agner at agner.org>:
>> Thanks for the tip. I had thought of using the demo facility for this
>> but I didn't know how to check for the operating system.
>
> See help about '.Platform'. I.e.,
>> .Platform$OS.type
> can be useful.
>
>> This is a clumsy solution, but better than nothing. I agree with Duncan
>> that there is a problem with the help system. It should either have a
>> way to embed formulas and graphics in .chm files, or a way to use .pdf
>> files for help under all operating systems. The latter solution is
>> probably easier to implement.
>>
>> Unfortunately, I personally don't have the time to contribute to
>> improving the help system of R. Maybe tasks like this could be offered
>> as projects to university students. Many students are doing useless
>> projects so why not use this resource for something useful.
>>
>> I have proposed to use R instead of Matlab for teaching math and signal
>> analysis at my university college, but I am not teaching math myself so
>> it's not my decision. If more universities were using R instead of
>> Matlab, Mathcad, SAS, etc. then they would also be motivated to
>> contribute to the development.
>>
>>
>> Dominick Samperi wrote:
>>
>>> Duncan Murdoch wrote:
>>>
>>>> On 11/7/2006 8:51 AM, Agner Fog wrote:
>>>>
>>>>
>>>>> I am building a package for various noncentral hypergeometric
>>>>> distributions.
>>>>>
>>>>> I want to include some heavy mathematical formulas. It appears that
>>>>> the build and INSTALL commands produce only .chm files and not .pdf
>>>>> files from my .Rd files under Windows. This means that it cannot
>>>>> show complicated mathematical formulas.
>>>>>
>>>>> The solution might be to include a .pdf file as a vignette. I tried
>>>>> that, but I can't find any way to link to the .pdf file or access it
>>>>> from any of the help facilities. The .pdf file is useless if the
>>>>> user can't find it.
>>>>>
>>>>
>>>>
>>>> Yes, that's a major problem in the current R help system.  You can
>>>> give the user code that would work to show the vignette, but there's
>>>> no way to create a live link to it.
>>>>
>>>
>>> The demo system can be used to compensate for limitations of the help
>>> system.
>>> You can display PDF files from any package subdirectory using a demo file
>>> like this (named demo/ReadPkgDoc.R, and documented in demo/00Index):
>>>
>>> # ReadPkgDoc.R -- Displays a PDF file as a demo
>>> #
>>> isWindows <- (Sys.info()['sysname'] == 'Windows')
>>> file <- system.file("doc", "PkgManual.pdf", package="PkgName")
>>> if(isWindows) { # Windows automatically finds executable based on file
>>> type.
>>>  system(paste("CMD /C ", file, "\n"))
>>> } else { # Change this to use path to Adobe reader if desired.
>>>  system(paste("xpdf ", file, "\n"))
>>> }
>>>
>>> To create the PDF file from the Rd file use R CMD Rd2dvi, and dvipdf.
>>>
>>> ds
>>>
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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