This is okay, I drop the bad lines, at least I hope I do:
conn <- textConnection(batch)
field.counts <- count.fields(conn, sep="\t", comment.char="", quote="")
close(conn)
good <- field.counts == 8 # this should drop all bad lines
if (!all(good))
batch <- batch[good]
conn <- textConnection(batch)
ret <- read.table(conn, sep="\t", comment.char="", quote="")
close(conn)
I get this error in read.table():
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 7151 did not have 8 elements
how come?!
You can do better than this in terms of providing clues for us:
"batch" is a character vector, right? So recheck that count.fields
returns all 8's after removal of bad lines. Also check that dimensions
match -- is length(batch) actually the same as length(field.counts)?