EVOLUTION-MANAGER
Edit File: include_graphics.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Embed external images in 'knitr' documents</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for include_graphics {knitr}"><tr><td>include_graphics {knitr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Embed external images in <span class="pkg">knitr</span> documents</h2> <h3>Description</h3> <p>When plots are not generated from R code, there is no way for <span class="pkg">knitr</span> to capture plots automatically. In this case, you may generate the images manually and pass their file paths to this function to include them in the output. The major advantage of using this function is that it is portable in the sense that it works for all document formats that <span class="pkg">knitr</span> supports, so you do not need to think if you have to use, for example, LaTeX or Markdown syntax, to embed an external image. Chunk options related to graphics output that work for normal R plots also work for these images, such as <code>out.width</code> and <code>out.height</code>. </p> <h3>Usage</h3> <pre> include_graphics( path, auto_pdf = getOption("knitr.graphics.auto_pdf", FALSE), dpi = NULL, error = getOption("knitr.graphics.error", TRUE) ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>path</code></td> <td> <p>A character vector of image paths.</p> </td></tr> <tr valign="top"><td><code>auto_pdf</code></td> <td> <p>Whether to use PDF images automatically when the output format is LaTeX. If <code>TRUE</code>, then e.g. ‘<span class="file">foo/bar.png</span>’ will be replaced by ‘<span class="file">foo/bar.pdf</span>’ if the latter exists. This can be useful since normally PDF images are of higher quality than raster images like PNG, when the output is LaTeX/PDF.</p> </td></tr> <tr valign="top"><td><code>dpi</code></td> <td> <p>DPI (dots per inch) value. Used to calculate the output width (in inches) of the images. This will be their actual width in pixels, divided by <code>dpi</code>. If not provided, the chunk option <code>dpi</code> is used; if <code>NA</code>, the output width will not be calculated.</p> </td></tr> <tr valign="top"><td><code>error</code></td> <td> <p>Whether to signal an error if any files specified in the <code>path</code> argument do not exist and are not web resources.</p> </td></tr> </table> <h3>Value</h3> <p>The same as the input character vector <code>path</code> but it is marked with special internal S3 classes so that <span class="pkg">knitr</span> will convert the file paths to proper output code according to the output format. </p> <h3>Note</h3> <p>This function is supposed to be used in R code chunks or inline R code expressions. You are recommended to use forward slashes (<code style="white-space: pre;">/</code>) as path separators instead of backslashes in the image paths. </p> <p>The automatic calculation of the output width requires the <span class="pkg">png</span> package (for PNG images) or the <span class="pkg">jpeg</span> package (for JPEG images). The width will not be calculated if the chunk option <code>out.width</code> is already provided or <code>dpi = NA</code>. </p> <hr /><div style="text-align: center;">[Package <em>knitr</em> version 1.29 <a href="00Index.html">Index</a>]</div> </body></html>