EVOLUTION-MANAGER
Edit File: capture.output.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: Send Output to a Character String or File</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 capture.output {utils}"><tr><td>capture.output {utils}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Send Output to a Character String or File</h2> <h3>Description</h3> <p>Evaluates its arguments with the output being returned as a character string or sent to a file. Related to <code><a href="../../base/html/sink.html">sink</a></code> in the same way that <code><a href="../../base/html/with.html">with</a></code> is related to <code><a href="../../base/html/attach.html">attach</a></code>. </p> <h3>Usage</h3> <pre> capture.output(..., file = NULL, append = FALSE, type = c("output", "message"), split = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>Expressions to be evaluated.</p> </td></tr> <tr valign="top"><td><code>file</code></td> <td> <p>A file name or a <a href="../../base/html/connections.html">connection</a>, or <code>NULL</code> to return the output as a character vector. If the connection is not open, it will be opened initially and closed on exit.</p> </td></tr> <tr valign="top"><td><code>append</code></td> <td> <p>logical. If <code>file</code> a file name or unopened connection, append or overwrite?</p> </td></tr> <tr valign="top"><td><code>type, split</code></td> <td> <p>are passed to <code><a href="../../base/html/sink.html">sink</a>()</code>, see there.</p> </td></tr> </table> <h3>Details</h3> <p>An attempt is made to write output as far as possible to <code>file</code> if there is an error in evaluating the expressions, but for <code>file = NULL</code> all output will be lost. </p> <p>Messages sent to <code><a href="../../base/html/showConnections.html">stderr</a>()</code> (including those from <code><a href="../../base/html/message.html">message</a></code>, <code><a href="../../base/html/warning.html">warning</a></code> and <code><a href="../../base/html/stop.html">stop</a></code>) are captured by <code>type = "message"</code>. Note that this can be “unsafe” and should only be used with care. </p> <h3>Value</h3> <p>A character string (if <code>file = NULL</code>), or invisible <code>NULL</code>. </p> <h3>See Also</h3> <p><code><a href="../../base/html/sink.html">sink</a></code>, <code><a href="../../base/html/textconnections.html">textConnection</a></code> </p> <h3>Examples</h3> <pre> require(stats) glmout <- capture.output(summary(glm(case ~ spontaneous+induced, data = infert, family = binomial()))) glmout[1:5] capture.output(1+1, 2+2) capture.output({1+1; 2+2}) ## Not run: ## on Unix-alike with a2ps available op <- options(useFancyQuotes=FALSE) pdf <- pipe("a2ps -o - | ps2pdf - tempout.pdf", "w") capture.output(example(glm), file = pdf) close(pdf); options(op) ; system("evince tempout.pdf &") ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>utils</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>