EVOLUTION-MANAGER
Edit File: with_tempfile.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: Temporary files</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 with_tempfile {withr}"><tr><td>with_tempfile {withr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Temporary files</h2> <h3>Description</h3> <p>Temporarily create a tempfile, which is automatically removed afterwards. </p> <h3>Usage</h3> <pre> with_tempfile( new, code, envir = parent.frame(), .local_envir = parent.frame(), pattern = "file", tmpdir = tempdir(), fileext = "" ) local_tempfile( new = NULL, lines = NULL, envir = parent.frame(), .local_envir = parent.frame(), pattern = "file", tmpdir = tempdir(), fileext = "" ) with_tempdir( code, clean = TRUE, pattern = "file", tmpdir = tempdir(), fileext = "" ) local_tempdir( pattern = "file", tmpdir = tempdir(), fileext = "", .local_envir = parent.frame(), clean = TRUE ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>new</code></td> <td> <p><code style="white-space: pre;">[character vector]</code><br /> (Deprecated for <code>local_tempfile()</code>) Names of temporary file handles to create.</p> </td></tr> <tr valign="top"><td><code>code</code></td> <td> <p><code>[any]</code><br /> Code to execute in the temporary environment</p> </td></tr> <tr valign="top"><td><code>envir</code></td> <td> <p><code style="white-space: pre;">[environment]</code><br /> Deprecated in favor of <code>.local_envir</code>.</p> </td></tr> <tr valign="top"><td><code>.local_envir</code></td> <td> <p><code style="white-space: pre;">[environment]</code><br /> The environment to use for scoping.</p> </td></tr> <tr valign="top"><td><code>pattern</code></td> <td> <p>a non-empty character vector giving the initial part of the name.</p> </td></tr> <tr valign="top"><td><code>tmpdir</code></td> <td> <p>a non-empty character vector giving the directory name</p> </td></tr> <tr valign="top"><td><code>fileext</code></td> <td> <p>a non-empty character vector giving the file extension</p> </td></tr> <tr valign="top"><td><code>lines</code></td> <td> <p>Optionally, supply lines to be fed into</p> </td></tr> <tr valign="top"><td><code>clean</code></td> <td> <p><code style="white-space: pre;">[logical(1)]</code><br /> A logical indicating if the temporary directory should be deleted after use (<code>TRUE</code>, default) or left alone (<code>FALSE</code>).</p> </td></tr> </table> <h3>Value</h3> <p><code>[any]</code><br /> The results of the evaluation of the <code>code</code> argument. </p> <h3>See Also</h3> <p><code><a href="withr.html">withr</a></code> for examples </p> <h3>Examples</h3> <pre> # check how big iris would be if written as csv vs RDS tf <- with_tempfile("tf", {write.csv(iris, tf); file.size(tf)}) tf <- with_tempfile("tf", {saveRDS(iris, tf); file.size(tf)}) </pre> <hr /><div style="text-align: center;">[Package <em>withr</em> version 2.5.0 <a href="00Index.html">Index</a>]</div> </body></html>