On 11-07-06 8:47 AM, Jannis wrote:
Dear list members,

is it somehow possible to include figures to the html help pages of individueal 
functions (containing for example a plot produced by that function?)

I thought about adding these figures into a 'graphs' subfolder of the package 
folder and then to somehow insert some sort of html link into the documentation 
code.

I use inlinedocs for creating the documentation.

Not in the current release, but this feature has been added to R-devel (which will be released at the end of October).

The simplest form is to put

\figure{filename.png}

into your help page. The "filename.png" file should be stored in the man/figures directory of your package.

You can also generate figures using R code, but it's a little tricky to make sure the generated files are stored in the right place. Here's an ugly example, which will probably be simpler by release time:

\Sexpr[stage=render,results=rd]{
     library(testpkg)  # This is the package with the example
     library(grDevices)
     filename <- tempfile(fileext=".png")
     png(file=filename)
     plot(rnorm(100))
     dev.off()
paste("\\\\ifelse{html}{\\\\figure{", file.path("../../../session", basename(filename)),
           "}}{\\\\figure{", normalizePath(filename, "/"), "}}", sep="")
}


Documentation on this is currently sparse, but it's there.

Duncan Murdoch

______________________________________________
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