Reputation: 1096
I have a big file containing about 100K rows. Each row is supposed to have 17 columns, but since some of the columns are missing for some of the rows, those rows seem to have columns less than 17. I want to know those rows beforehand and not read them. How is this possible in R? Thanks.
Upvotes: 1
Views: 410
Reputation: 206187
The count.fields()
function does exactly this. It takes most of the same parameters that read.table()
would use. See the ?count.fields
help page for more info.
fc <- count.fields("myfile.txt")
which(fc != 17)
Upvotes: 6