EVOLUTION-MANAGER
Edit File: fig_chunk.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: Obtain the figure filenames for a chunk</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 fig_chunk {knitr}"><tr><td>fig_chunk {knitr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Obtain the figure filenames for a chunk</h2> <h3>Description</h3> <p>Given a chunk label, the figure file extension, the figure number(s), and the chunk option <code>fig.path</code>, return the filename(s). </p> <h3>Usage</h3> <pre> fig_chunk(label, ext = "", number, fig.path = opts_chunk$get("fig.path")) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>label</code></td> <td> <p>The chunk label.</p> </td></tr> <tr valign="top"><td><code>ext</code></td> <td> <p>The figure file extension, e.g. <code>png</code> or <code>pdf</code>.</p> </td></tr> <tr valign="top"><td><code>number</code></td> <td> <p>The figure number (by default <code>1</code>).</p> </td></tr> <tr valign="top"><td><code>fig.path</code></td> <td> <p>Passed to <code><a href="fig_path.html">fig_path</a></code>. By default, the chunk option <code>fig.path</code> is used.</p> </td></tr> </table> <h3>Details</h3> <p>This function can be used in an inline R expression to write out the figure filenames without hard-coding them. For example, if you created a plot in a code chunk with the label <code>foo</code> and figure path ‘<span class="file">my-figure/</span>’, you are not recommended to use hard-coded figure paths like <span class="samp">\includegraphics{my-figure/foo-1.pdf}</span> (in ‘<span class="file">.Rnw</span>’ documents) or <span class="samp"></span> (R Markdown) in your document. Instead, you should use <span class="samp">\Sexpr{fig_chunk('foo', 'pdf')}</span> or <span class="samp">`)</span>. </p> <p>You can generate plots in a code chunk but not show them inside the code chunk by using the chunk option <code>fig.show = 'hide'</code>. Then you can use this function if you want to show them elsewhere. </p> <h3>Value</h3> <p>A character vector of filenames. </p> <h3>Examples</h3> <pre> library(knitr) fig_chunk("foo", "png") fig_chunk("foo", "pdf") fig_chunk("foo", "svg", 2) # the second plot of the chunk foo fig_chunk("foo", "png", 1:5) # if the chunk foo produced 5 plots </pre> <hr /><div style="text-align: center;">[Package <em>knitr</em> version 1.29 <a href="00Index.html">Index</a>]</div> </body></html>