title: R: Why does read.table stop reading a file?
body: <p>I have a file, called <code>genes.txt</code>, which I'd like to become a data.frame. It's got a lot of lines, each line has three, tab delimited fields:</p>
  
  <pre><code>mike$ wc -l genes.txt
     42476 genes.txt
  </code></pre>
  
  <p>I'd like to read this file into a data.frame in R. I use the command read.table, like this:</p>
  
  <pre><code>genes = read.table(
      genes_file, 
      sep="\t", 
      na.strings="-", 
      fill=TRUE,
      col.names=c("GeneSymbol","synonyms","description")
  )
  </code></pre>
  
  <p>Which seems to work fine, where <code>genes_file</code> points at <code>genes.txt</code>. However, the number of lines in my data.frame is significantly less than the number of lines in my text file:</p>
  
  <pre><code>&gt; nrow(genes)
  [1] 27896
  </code></pre>
  
  <p>and things I can find in the text file:</p>
  
  <pre><code>mike$ grep "SELL" genes.txt 
  SELL    CD62L|LAM1|LECAM1|LEU8|LNHR|LSEL|LYAM1|PLNHR|TQ1    selectin L
  </code></pre>
  
  <p>don't seem to be in the data.frame</p>
  
  <pre><code>&gt; grep("SELL",genes$GeneSymbol)
  integer(0)
  </code></pre>
  
  <p>it turns out that </p>
  
  <pre><code>genes = read.delim(
      genes_file,
      header=FALSE,
      na.strings="-",
      fill=TRUE,
      col.names=c("GeneSymbol","synonyms","description"),
  )
  </code></pre>
  
  <p>works just fine. Why does read.delim work when read.table not?</p>
  
  <p>If it's of use, you can recreate <code>genes.txt</code> using the following commands which you should run from a command line</p>
  
  <pre><code>curl -O ftp://ftp.ncbi.nlm.nih.gov/gene/DATA/gene_info.gz
  gzip -cd gene_info.gz | awk -Ft '$1==9606{print $3 "\t" $5 "\t" $9}' &gt; genes.txt
  </code></pre>
  
  <p>be warned, though, that gene_info.gz is 101MBish.</p>