title: R: How to divide several columns into equal and equivalent parts, reduce the number of columns, and reallocate data?
body: <p>I have a data frame that looks like this:</p>
   
  <pre class="lang-r prettyprint-override"><code>&quot;ID&quot; &quot;condition&quot; &quot;E_01&quot; &quot;E_02&quot; &quot;E_03&quot; &quot;E_04&quot;...
  &quot;ID01&quot; &quot;cond1&quot;    0.1    0.2    0.1    N/A
  &quot;ID01&quot; &quot;cond2&quot;    N/A    N/A    N/A    0.1
  &quot;ID01&quot; &quot;cond3&quot;    N/A    N/A    N/A    N/A
  &quot;ID02&quot; &quot;cond1&quot;    0.1    0.2    0.1    N/A
  ...
  </code></pre>
  <p>where the <code>E_XY</code> labels continue until <code>N</code>.</p>
  <p>If we assume <code>N=9</code> I would like to first split <code>N</code> into equal and equivalent parts, for example 3, to retrieve <code>&quot;T_01&quot;, &quot;T_02&quot;, &quot;T_03&quot;</code> three times, and next, reallocate the data to get rid of the <code>N/A</code>s as illustrated in the desired output.
  (<code>&quot;E_01&quot;,&quot;E_04&quot;,&quot;E_07&quot;</code> all belong to <code>&quot;T_01&quot;</code>;  <code>&quot;E_02&quot;,&quot;E_05&quot;,&quot;E_08&quot;</code> all belong to <code>&quot;T_02&quot;</code> etc.)</p>
  <p>Desired output:</p>
  <pre class="lang-r prettyprint-override"><code>&quot;ID&quot; &quot;condition&quot; &quot;T_01&quot; &quot;T_02&quot; &quot;T_03&quot;
  &quot;ID01&quot; &quot;cond1&quot;    0.1    0.2    0.1
  &quot;ID01&quot; &quot;cond2&quot;    0.1    0.2    0.1
  &quot;ID01&quot; &quot;cond3&quot;    0.1    0.2    0.1
  &quot;ID02&quot; &quot;cond1&quot;    0.1    0.2    0.1
  ...
  
  </code></pre>
  <p>Does anyone know a smart way to do this?</p>