EVOLUTION-MANAGER
Edit File: write.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: Write Data to a 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 write {base}"><tr><td>write {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Write Data to a File</h2> <h3>Description</h3> <p>The data (usually a matrix) <code>x</code> are written to file <code>file</code>. If <code>x</code> is a two-dimensional matrix you need to transpose it to get the columns in <code>file</code> the same as those in the internal representation. </p> <h3>Usage</h3> <pre> write(x, file = "data", ncolumns = if(is.character(x)) 1 else 5, append = FALSE, sep = " ") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>the data to be written out, usually an atomic vector.</p> </td></tr> <tr valign="top"><td><code>file</code></td> <td> <p>a <code><a href="connections.html">connection</a></code>, or a character string naming the file to write to. If <code>""</code>, print to the standard output connection. </p> <p>When <code><a href="Platform.html">.Platform</a>$OS.type != "windows"</code>, and it is <code>"|cmd"</code>, the output is piped to the command given by ‘<span class="file">cmd</span>’. </p> </td></tr> <tr valign="top"><td><code>ncolumns</code></td> <td> <p>the number of columns to write the data in.</p> </td></tr> <tr valign="top"><td><code>append</code></td> <td> <p>if <code>TRUE</code> the data <code>x</code> are appended to the connection.</p> </td></tr> <tr valign="top"><td><code>sep</code></td> <td> <p>a string used to separate columns. Using <code>sep = "\t"</code> gives tab delimited output; default is <code>" "</code>.</p> </td></tr> </table> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code>write</code> is a wrapper for <code><a href="cat.html">cat</a></code>, which gives further details on the format used. </p> <p><code><a href="save.html">save</a></code> for writing any <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> objects, <code><a href="../../utils/html/write.table.html">write.table</a></code> for data frames, and <code><a href="scan.html">scan</a></code> for reading data. </p> <h3>Examples</h3> <pre> # create a 2 by 5 matrix x <- matrix(1:10, ncol = 5) fil <- tempfile("data") # the file data contains x, two rows, five cols # 1 3 5 7 9 will form the first row write(t(x), fil) if(interactive()) file.show(fil) unlink(fil) # tidy up # Writing to the "console" 'tab-delimited' # two rows, five cols but the first row is 1 2 3 4 5 write(x, "", sep = "\t") </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>