count.fields
counts the number of fields, as separated by
sep
, in each of the lines of file
read.count.fields(file, sep = "", quote = "\"'", skip = 0,
blank.lines.skip = TRUE, comment.char = "#")
connection
, which will be opened if necessary,
and if so closed at the end of the function call.TRUE
blank lines in the
input are ignored.read.table
and can still be
useful in discovering problems in reading a file by that function. For the handling of comments, see scan
. Consistent with scan
, count.fields
allows
quoted strings to contain newline characters. In such a case the
starting line will have the field count recorded as NA
, and
the ending line will include the count of all fields from the
beginning of the record.read.table
cat("NAME", "1:John", "2:Paul", file = "foo", sep = "\n")
count.fields("foo", sep = ":")
unlink("foo")
Run the code above in your browser using DataLab