[R] including figures in html documentation/help

Jannis bt_jannis at yahoo.de
Wed Jul 6 16:03:43 CEST 2011


Thanks for your advice Duncan. In which file should I put the 

\figure{}

command? I tried the *.Rd file, but the html files created are without the figure. Are you sure I only need to include the filename and no path?


Jannis

--- Duncan Murdoch <murdoch.duncan at gmail.com> schrieb am Mi, 6.7.2011:

> Von: Duncan Murdoch <murdoch.duncan at gmail.com>
> Betreff: Re: [R] including figures in html documentation/help
> An: "Jannis" <bt_jannis at yahoo.de>
> CC: r-help at r-project.org
> Datum: Mittwoch, 6. Juli, 2011 13:04 Uhr
> 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
>



More information about the R-help mailing list