Problem Statement: Reading Fewer Lines with read.table Command
I have been learning the naive bayes classification. I downloaded this SMS collection data. I went ahead and tried to load the data using following command. And, it listed around 1630 rows, although there were 5574 rows.
messages <- read.table( file.choose(), sep="\t", stringsAsFactors=FALSE)
I check with commands such as dim(messages) and it gave me 1630 messages with 2 columns. This is lesser (and thus, incorrect) than what existed in the document.
Solution to getting exact number of rows
After investigation, I found that the messages consisted of single/double quotes and this needed to be disabled for read.table to read correct number of rows. I did the same with following command and it worked pretty well. Note the usage quote=” parameter.
messages <- read.table( file.choose(), sep="\t", stringsAsFactors=FALSE, quote='')