The following graph is embedded in the document using the img
function
html{
[results=rd, stage=build, echo=FALSE]{
library( base64 )
library( grDevices )
library( graphics )
library( stats )
pngfile <- tempfile()
png( pngfile, width = 600, height = 400 )
plot( 1:100, rnorm(100), pch = 21, bg = "red", cex = 2 )
dev.off()
img( pngfile, Rd = TRUE )
}{ (only when rendered in html) }}
img(file, Rd = FALSE, alt = "image" )
- file
{png file to translate into a data uri}
- Rd
{if TRUE, extra markup is added to facilitate inclusion of the image in an Rd file}
- alt
{alternate text}
The html code
Wikipedia entry for data uri http://en.wikipedia.org/wiki/Data_URI_scheme
[object Object]
no checking on the file is performed, so it is up to the user to
make sure the input file is indeed a png file
encode is used to encode the file
pngfile <- tempfile()
png( pngfile, width = 600, height = 600 )
plot( 1:100, rnorm(100), pch = 21, bg = "red", cex = 2 )
dev.off()
img( pngfile )
programming