Skip to content
Prev 36372 / 63424 Next

inject html code into Rd file

Le 03/04/10 02:04, Duncan Murdoch a ?crit :
Thanks.
This gives one way to include images in a Rd file with data uri, here is 
a proof of concept (that depends on openssl to do the base 64 encoding):

img <- function(){
	tf <- tempfile()
	tf.out <- tempfile()
	png( tf, width = 500, height = 500)
	plot( 1:100, rnorm(100), pch = 21, bg = "red", cex =2 )
	dev.off()
	system( sprintf( 'openssl base64 -in "%s" -out "%s" ', tf, tf.out ) )
	sprintf( '\\out{<img src="data:image/png;base64,%s" />}',
		paste( readLines( tf.out), collapse = "\n" ) )
}

and the Rd file:

\name{test}
\alias{test}
\title{test}
\description{
\if{html}{
\Sexpr[stage=render,results=rd,echo=FALSE]{
	source( "test.R" )
	img()
}
}
}



It might be interesting to have something like results=asis or something.

Romain