EVOLUTION-MANAGER
Edit File: readLines.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: Read text lines from 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 readLines {brio}"><tr><td>readLines {brio}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Read text lines from a file</h2> <h3>Description</h3> <p>This is a drop in replacement for <code><a href="../../base/html/readLines.html">base::readLines()</a></code> with restricted functionality. Compared to <code><a href="../../base/html/readLines.html">base::readLines()</a></code> it: </p> <ul> <li><p> Only works with file paths, not connections. </p> </li> <li><p> Assumes the files are always UTF-8 encoded. </p> </li> <li><p> Does not warn or skip embedded nulls, they will likely crash R. </p> </li> <li><p> Does not warn if the file is missing the end of line character. </p> </li> <li><p> The arguments <code>ok</code>, <code>warn</code>, <code>encoding</code> and <code>skipNul</code> are ignored, with a warning. </p> </li></ul> <h3>Usage</h3> <pre> readLines(con, n = -1, ok, warn, encoding, skipNul) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>con</code></td> <td> <p>A character string of the path to a file. Throws an error if a connection object is passed.</p> </td></tr> <tr valign="top"><td><code>n</code></td> <td> <p>integer. The number of lines to read. A negative number means read all the lines in the file.</p> </td></tr> <tr valign="top"><td><code>ok</code></td> <td> <p>Ignored, with a warning.</p> </td></tr> <tr valign="top"><td><code>warn</code></td> <td> <p>Ignored, with a warning.</p> </td></tr> <tr valign="top"><td><code>encoding</code></td> <td> <p>Ignored, with a warning.</p> </td></tr> <tr valign="top"><td><code>skipNul</code></td> <td> <p>Ignored, with a warning.</p> </td></tr> </table> <h3>Value</h3> <p>A UTF-8 encoded character vector of the lines in the file. </p> <h3>See Also</h3> <p><code><a href="writeLines.html">writeLines()</a></code> </p> <h3>Examples</h3> <pre> authors_file <- file.path(R.home("doc"), "AUTHORS") data <- readLines(authors_file) # Trying to use connections throws an error con <- file(authors_file) try(readLines(con)) close(con) # Trying to use unsupported args throws a warning data <- readLines(authors_file, encoding = "UTF-16") </pre> <hr /><div style="text-align: center;">[Package <em>brio</em> version 1.1.3 <a href="00Index.html">Index</a>]</div> </body></html>