title: Data manipulation for pairwise.t.test in R
body: <p>So I'm trying to do a pairwise table and retain a p-value of each pair.
  Please be noted that I'm still a beginner to R.
  My data looks like this (though much bigger):</p>
  
  <pre><code>a &lt;- factor(c("ID1","ID2","ID3","ID4","ID5"))
  b &lt;- runif(5)
  b1 &lt;- runif(5)
  b2 &lt;- runif(5)
  b3 &lt;- runif(5)
  c1 &lt;- runif(5)
  c2 &lt;- runif(5)
  c3 &lt;- runif(5)
  df &lt;- data.frame(a,b1,b2,b3,c1,c2,c3)
  </code></pre>
  
  <p>Where b1,b2,b3 should be compared to c1,c2,c3 for each row (for each ID in column a).
  The end result should be something like:</p>
  
  <pre><code>a &lt;- cbind(a,Adjusted_P_Values)
  </code></pre>
  
  <p>Where the head(a,1) would look like:</p>
  
  <pre><code>head(a,1)
      a        b1        b2        b3        c1        c2
  1 ID1 0.1337694 0.7347543 0.5808391 0.4324976 0.5378458
           c3        Adjusted_P_value
  1 0.6368778        0.99
  </code></pre>
  
  <p>where each row has its corresponding P-value.
  A function I have found which I think could do the trick is <code>pairwise.t.test</code>.
  (Currently, I'm just running a loop for each row and doing a normal t-test and then correct them with p.adjust, but I can't do pooled sd---which I would like.)</p>
  
  <p>So my issue now is how I construct the data so that R likes it. I can use <code>melt.data.frame</code>from reshape2 library, but it wont give me the correct structure.
  I use it like this:</p>
  
  <pre><code>Test_Data &lt;- melt(df, "a", c("b1","b2","b3","c1","c2","c3"))
  </code></pre>
  
  <p>But I loose the row symmetry.
  As, when I now do <code>pairwise.t.test</code> I have to use either the "a" column or the "variable" column created by melt, hence I either get a comparison between the replicates or between the IDs.
  So, simply my question is:
  how do I structure the data so that each row is tested and I get a p-value for each row, and where each treatment (b or c) has a standard deviation based on all the rows (one sd for all b's and one for all c's)?
  I have been googeling a lot looking for similar problems (and tutorials on pairwise.t.test) but without success.</p>