EVOLUTION-MANAGER
Edit File: count.fields.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: Count the Number of Fields per Line</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 count.fields {utils}"><tr><td>count.fields {utils}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Count the Number of Fields per Line</h2> <h3>Description</h3> <p><code>count.fields</code> counts the number of fields, as separated by <code>sep</code>, in each of the lines of <code>file</code> read. </p> <h3>Usage</h3> <pre> count.fields(file, sep = "", quote = "\"'", skip = 0, blank.lines.skip = TRUE, comment.char = "#") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>file</code></td> <td> <p>a character string naming an ASCII data file, or a <code><a href="../../base/html/connections.html">connection</a></code>, which will be opened if necessary, and if so closed at the end of the function call.</p> </td></tr> <tr valign="top"><td><code>sep</code></td> <td> <p>the field separator character. Values on each line of the file are separated by this character. By default, arbitrary amounts of whitespace can separate fields.</p> </td></tr> <tr valign="top"><td><code>quote</code></td> <td> <p>the set of quoting characters</p> </td></tr> <tr valign="top"><td><code>skip</code></td> <td> <p>the number of lines of the data file to skip before beginning to read data.</p> </td></tr> <tr valign="top"><td><code>blank.lines.skip</code></td> <td> <p>logical: if <code>TRUE</code> blank lines in the input are ignored.</p> </td></tr> <tr valign="top"><td><code>comment.char</code></td> <td> <p>character: a character vector of length one containing a single character or an empty string.</p> </td></tr> </table> <h3>Details</h3> <p>This used to be used by <code><a href="read.table.html">read.table</a></code> and can still be useful in discovering problems in reading a file by that function. </p> <p>For the handling of comments, see <code><a href="../../base/html/scan.html">scan</a></code>. </p> <p>Consistent with <code><a href="../../base/html/scan.html">scan</a></code>, <code>count.fields</code> allows quoted strings to contain newline characters. In such a case the starting line will have the field count recorded as <code>NA</code>, and the ending line will include the count of all fields from the beginning of the record. </p> <h3>Value</h3> <p>A vector with the numbers of fields found. </p> <h3>See Also</h3> <p><code><a href="read.table.html">read.table</a></code> </p> <h3>Examples</h3> <pre> fil <- tempfile() cat("NAME", "1:John", "2:Paul", file = fil, sep = "\n") count.fields(fil, sep = ":") unlink(fil) </pre> <hr /><div style="text-align: center;">[Package <em>utils</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>