title: Dividing each row of data frames within a list by a corresponding matrix value
body: <p>I have a list of 3 data frames, each with 3 rows (<code>op2</code>) and a matrix (<code>rep_totals</code>). Each row of each data frame relates to a value in my matrix, with the trend: <code>op2[[i]][j,]</code> corresponding to <code>rep_totals[i,j]</code></p>
  
  <p>I would like to divide each row of each data frame in <code>op2</code> by its corresponding value in <code>rep_total</code>s to yield a list of 3 new data frames (<code>gt_freqs</code>) with their adjusted values.</p>
  
  <p>Here is what I have tried:</p>
  
  <pre><code>x = matrix(5,3,5) # creating example
  x = as.data.frame(x)
  op2 = list(x,x,x)
  rep_totals = matrix(5,3,3)
  
  gt_freqs &lt;- replicate(length(op2), matrix(0, 3, 5), simplify = FALSE)
  for(i in seq_along(op2)) for(j in seq_along(op2[[1]][1:3,])) gt_freqs[[i]] &lt;- op2[[i]][j,]/rep_totals[i,j]
  </code></pre>
  
  <p>So in this example the intended output would be 3 data frames of the same size as <code>op2</code>, except the values would all be adjusted to 1</p>
  
  <p>Thanks in advance for your help!</p>