Evaluates a plotting expression in a temporary PNG device and returns
the resulting image as a self-contained, base64-encoded <img>
tag (class "html", see asHtml()), suitable for
embedding directly in HTML text – a report, a question, an e-mail.
Arguments
- expr
a plotting expression, evaluated once inside the device. A character string is not accepted: pass the plotting code itself, e.g.
asImg(plot(1:10))instead ofasImg("plot(1:10)").- width, height
size of the device in pixels
- res
nominal resolution in dpi, which also scales the text: raise it for a larger picture with the same relative proportions
- ...
further arguments passed to
grDevices::png()
Value
an object of class c("html", "character") containing an
<img> tag with a data:image/png;base64,... source
Details
The expression is passed unevaluated and carries its own environment, so a plot built inside a function sees that function's local variables. Several statements are given in braces, as in the examples below.
See also
Other html:
asFileLink(),
asHtml(),
embedFile(),
escapeHtml(),
htmlNotation,
htmlSubscript,
preview(),
preview.html(),
toHtmlTable()
