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. I have placed the .pdf file under inst\doc\ together with an index.html file. I have tried to link to the .pdf file from an .Rd file with \link{packagename/doc/xxx.pdf}
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. There are a lot of problems with the help system, and vague plans to fix them, but there are a lot of meta-problems as well: there is no agreement on whether it should it be a complete rewrite or an incremental fix, no agreement on exactly what the goals of the system should be (e.g. should help("foo") try to guess what the user meant when the exact topic "foo" was not found), there's more energy spent on criticizing proposed changes than on implementing anything at all, and there's nobody who has the time and energy to fight against all of this to actually do anything about it. Duncan Murdoch> I have placed the .pdf file under inst\doc\ together with an index.html > file. > I have tried to link to the .pdf file from an .Rd file with > \link{packagename/doc/xxx.pdf}
Dirk Eddelbuettel wrote:> There is options("pdfviewer") -- at least under Unix. Maybe there is > even an R call to use it on a file, employed by the help system? > DirkThanks, Here is a more complete solution that can be turned into a general-purpose function... # Displays PDF file as an R demo # pkgName <- 'MyPackage' pkgDir <- 'doc' pdfFile <- 'MyPackageDoc.pdf' isWindows <- (Sys.info()['sysname'] == 'Windows') pkgLoc <- system.file(".", ".", package=pkgName) pkgLoc <- substring(pkgLoc, 1, nchar(pkgLoc)-nchar(pkgName)-5) file <- system.file(pkgDir, pdfFile, package=pkgName,lib.loc=pkgLoc) 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(options("pdfviewer"), file, "\n")) }