| hwriteImage {hwriter} | R Documentation |
Inserts an image in an HTML document. The image can be either an external one specified by an URL or can be captured from the current graphic device.
hwriteImage(image.url, page=NULL, image.border=0, width=NULL, height=NULL, capture=FALSE, ...)
image.url |
a character vector containing the URL of an image, which can be also a path to a local filename. |
page |
an optional connection, a character string naming the file to write
to or a page object returned by openPage. |
image.border |
an optional numeric value specifiying the width of the image border. Default is 0. |
width, height |
an optional HTML length unit (in pixels) specifiying the width (resp. height) at which the image should be rendered. If missing, the default image width (resp. height) will be used. |
capture |
a logical. If TRUE the image from the current
graphic device is captured and written as a PNG file to the filename specified by
image.url. Capture resolution is controlled by width
and height, which have a default value of 400 pixels. Default is FALSE. |
... |
optional arguments that will be dispatched to the
underlying hwrite call. |
hwriteImage constructs an HTML <img> tag to insert a image. This function can be seamlessly in conjuction with hwrite
to position an image. The capture argument enables to capture
easily a current plot and to insert it in a web page.
By default, if image.url is a vector the output value will be a
character string containing the HTML code of a table containing the
images. This behaviour is dictated by the underlying hwrite call
made by hwriteImage. The argument table can be set to
TRUE to obtain a vector of HTML image tags instead.
A character vector containing the output HTML code.
Gregoire Pau, gpau@ebi.ac.uk, 2008
## Creates a new web page 'test.html'
tmpdir <- tempdir()
p <- openPage('test.html', dirname=tmpdir)
## Insert an external image
img <- hwriteImage('http://www.ebi.ac.uk/~gpau/hwriter/iris1.jpg', center=TRUE)
hwrite(c(img,caption='Iris'), p, dim=c(2,1),
row.style=list(caption='text-align:center;background-color:#fac'),
row.names=FALSE, br=TRUE)
## Closes the web page
closePage(p)
## Opens a web browser to see the result
if (interactive()) try(browseURL(file.path(tmpdir, 'test.html')))