title: How to rearrange two factor data in R to run two way ANOVA?
body: <p>I need to run two way ANOVA and post-hoc test in R.
  And I have a CSV file like this:</p>
  
  <pre><code>BLOCK,AdvTraining,Destillation,Squeezing
  Clean,4,3,10
  Clean,10,3,13
  Clean,4,1,8
  FGSM,402,237,521
  FGSM,290,129,483
  FGSM,407,262,568
  BIM,998,14,285
  BIM,972,9,321
  BIM,994,12,451
  DeepFool,421,419,661
  DeepFool,410,425,663
  DeepFool,378,386,585
  </code></pre>
  
  <p>There are 4 blocks (Clean, FGSM, BIM, DeepFool) and 3 treatments (AdvTraining, Destillation, Squeezing). </p>
  
  <p>All blocks have same number of samples, without missing value.</p>
  
  <p>This file is intended to run two way ANOVA from excel.</p>
  
  <p>I notice R require a single column structure, something like this:</p>
  
  <pre><code>Clean,AdvTraining,4
  Clean,Destillation,3
  Clean,Squeezing,10
  ...
  DeepFool,AdvTraining,378
  DeepFool,Destillation,386
  DeepFool,Squeezing,585
  </code></pre>
  
  <p>How can I do this?</p>
  
  <p>Notice that the actual file is much larger.
  It has more blocks and more than 500 rows.
  So changing it manually isn't an option.</p>