title: How to melt two groups of data into two columns in R?
body: <p>I have this data below. I want to melt all <code>No_of.reads</code> cloumns in one column and all <code>_contamination_</code> columns in another column. So the final dataframe would have <code>diluted_sample</code>, <code>No_of_reads</code> and <code>_contamination_</code> columns. I tried to do this in two steps, but this would give me repeated observations. What is the right way to do it?</p>
  
  <p>code:</p>
  
  <pre><code>test.dput.melted &lt;- melt(test.dput, id = 1:3, measure = 4:7)
  test.dput.melted &lt;- melt(test.dput.melted, id = c(1,4,5), measure = 2:3)
  </code></pre>
  
  <p>Data:</p>
  
  <pre><code> test.dput&lt;- structure(list(diluted_sample = c("100%", "95%", "90%", "85%", 
  "80%", "75%"), No_of_reads_from_NA12878 = c("15,000,000", "14,250,000", 
  "13,500,000", "12,750,000", "12,000,000", "11,250,000"), No_of_reads_from_NA12877 = c("0", 
  "750,000", "1,500,000", "2,250,000", "3,000,000", "3,750,000"
  ), tEst_contamination_of_NA12878 = c("99.60%", "99.10%", "96.80%", 
  "92.60%", "88%", "82.60%"), pair_contamination_of_NA12878 = c("100.00%", 
  "94.15%", "88.72%", "83.36%", "78.20%", "73.08%"), tEst_contamination_of_NA12877 = c("0.10%", 
  "7%", "13.60%", "20.10%", "26.20%", "32.10%"), pair_contamination_of_NA12877 = c("0.10%", 
  "5.21%", "10.50%", "15.85%", "20.92%", "26.04%")), .Names = c("diluted_sample", 
  "No_of_reads_from_NA12878", "No_of_reads_from_NA12877", "tEst_contamination_of_NA12878", 
  "pair_contamination_of_NA12878", "tEst_contamination_of_NA12877", 
  "pair_contamination_of_NA12877"), row.names = c(NA, 6L), class = "data.frame")
  </code></pre>