title: Subset data frame based on column values
body: <p>I have a data frame consisting of the fluorescence read out of multiple cells tracked over time, for example:</p>
  
  <pre><code>Number=c(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4)
  Fluorescence=c(9,10,20,30,8,11,21,31,6,12,22,32,7,13,23,33)
  df = data.frame(Number, Fluorescence)
  </code></pre>
  
  <p>Which gets:</p>
  
  <pre><code>   Number Fluorescence
  1       1            9
  2       2           10
  3       3           20
  4       4           30
  5       1            8
  6       2           11
  7       3           21
  8       4           31
  9       1            6
  10      2           12
  11      3           22
  12      4           32
  13      1            7
  14      2           13
  15      3           23
  16      4           33
  </code></pre>
  
  <p>Number pertains to the cell number. What I want is to collate the fluorescence readout based on the cell number. The data.frame here has it counting 1-4, whereas really I want something like this:</p>
  
  <pre><code>   Number Fluorescence
  1       1            9
  2       1            8
  3       1            6
  4       1            7
  5       2           10
  6       2           11
  7       2           12
  8       2           13
  9       3           20
  10      3           21
  11      3           22
  12      3           23
  13      4           30
  14      4           31
  15      4           32
  16      4           33
  </code></pre>
  
  <p>Or even more ideal would be having columns based on Number, then respective cell fluorescence:</p>
  
  <pre><code>        1    2    3    4
  1       9    10   20   30
  2       8    11   21   31
  3       6    12   22   32
  4       7    13   23   33
  </code></pre>
  
  <p>I've used the which function to extract them one at a time:</p>
  
  <pre><code>Cell1=df[which(df[,1]==1),2]
  </code></pre>
  
  <p>But this would require me to write a line for each cell (of which there are hundreds).</p>
  
  <p>Thank you for any help with this! Apologies that I'm still a bit of an R noob.</p>