title: Rescale the values for sum of numbers in R
body: <p>If I have these data frames</p>
  <pre><code>df1&lt;- as.numeric(c(&quot;20&quot;, &quot;25&quot;, &quot;15&quot;, &quot;50&quot;))
  
  df2&lt;- as.numeric (c(&quot;15&quot;, &quot;20&quot;, &quot;10&quot;, &quot;5&quot;))
  
  df3&lt;- as.numeric(c(&quot;10&quot;, &quot;7&quot;, &quot;15&quot;, &quot;13&quot;))
  
  my_list &lt;- list(df1, df2, df3)
  
  sum_dat &lt;- as.numeric(c(&quot;180&quot;, &quot;90&quot;, &quot;5&quot;))
  </code></pre>
  <p>Here I want the data frames in list my_list i.e. the numbers in df1 to be rescaled such that the sum of df1 (20+25+15+50) is close to or equal to 180, df2 sums to be equal to 90, and df 3 sum equal to 5.</p>