title: Transpose rows to columns and remove only NAs in resulting columns
body: <p>I am trying to write code to go from an input file of this type</p>
  
  <pre><code>dput(input)
  c("A\t8213", "B\tAnytown", "C\tAAA", "D\t19", "E\t19", "F\tAny ID", 
  "G\t0", "H\t0", "I\t0", "J\t0", "K\t0", "L\t0", "M\t0", "N\t0.048", 
  "O\t0.303", "P\t31", "Q\t0", "R\t-0.114", "S\t0.377", "T\t-5.833"
  )
  </code></pre>
  
  <p>to an output file of this type (once the code is verified for one file, then it will be used in a function to process hundreds of files):</p>
  
  <pre><code>dput(output)
  c("A\tB\tC\tD\tE\tF\tG\tH\tI\tJ\tK\tL\tM\tN\tO\tP\tQ\tR\tS\tT", 
  "8213\tAnytown\tAAA\t19\t19\tAny  
  ID\t0\t0\t0\t0\t0\t0\t0\t0.048\t0.303\t31\t0\t-0.114\t0.377\t-5.833", 
  "")
  </code></pre>
  
  <p>I only want the rows where there is no NA in each column.</p>
  
  <p>This is the code that I have written thus far (I am thankful for many useful code snippets at StackOverflow and R help mailing lists for the following revised code)</p>
  
  <pre><code>library(data.table)
  inputtmp &lt;- data.table(read.table(textConnection(input), sep = "\t",     
  stringsAsFactors = FALSE))
  inputtmp[, id:=1:length(inputtmp[[1]])]
  inputtmp &lt;- dcast.data.table(inputtmp, id~V1, value.var="V2")
  varcols &lt;- colnames(inputtmp)
  </code></pre>
  
  <p>Questions:</p>
  
  <p>1) Is there a better way to "transpose" the rows to columns so that other steps are not needed to remove the NAs?</p>
  
  <p>2) If not, then how can I remove only the NAs from each column?</p>
  
  <p>I have tried different revisions of code presented in the following 2 links, but nothing has worked in my case.</p>
  
  <p>1) <a href="https://stackoverflow.com/questions/13755547/fastest-way-to-drop-rows-with-missing-values">Fastest way to drop rows with missing values?</a></p>
  
  <p>and</p>
  
  <p>2) <a href="https://stackoverflow.com/questions/20077207/apply-over-rows-of-data-table-find-rows-where-a-subset-of-columns-are-all-na?rq=1">Apply over rows of data.table: find rows where a subset of columns are all NA</a></p>
  
  <p>Thank you.</p>