title: Normalize multiple values using values of one factor in R
body: <p>We have some tidy data with treatments (multiple samples and control), time points, and measured values. I want to normalize all the samples by dividing by the corresponding time point in the control variable. </p>
  
  <p>I know how I would do this with each value in its own column, but can't figure out how to us a combination of <code>gather</code> <code>mutate</code>, <code>sumamrise</code> etc from <code>tidyr</code> or <code>dplyr</code> to do this in a straightforward way. </p>
  
  <p>Here is a sample data frame definition: </p>
  
  <pre><code>structure(list(time = c(1, 2, 3, 1, 2, 3, 1, 2, 3), 
  value = c(10, 20, 15, 100, 210, 180, 110, 180, 140), 
  as.factor.treat. = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L), 
  .Label = c("c", "t1", "t2"), class = "factor")), 
  .Names = c("time", "value", "treat"), 
  row.names = c(NA, -9L), class = "data.frame")
  </code></pre>
  
  <p>Data frame looks like this:</p>
  
  <pre><code>time value   treat
     1    10      c
     2    20      c
     3    15      c
     1   100     t1
     2   210     t1
     3   180     t1
     1   110     t2
     2   180     t2
     3   140     t2
  </code></pre>
  
  <p>Expected output. same but with <code>normvalue</code> column containing <code>c(1,1,1,10,10.5,12,11,9,9.333333)</code></p>
  
  <p>I'd like to get out columns of normalized <code>value</code> for each treatment and time point using tidyverse procedures... </p>