title: Is there a way or a built in R function that can sum the values of duplicate names within a list?
body: <p>lets say I have this list:</p>
  
  <pre><code>values &lt;- list(2, 8, 3, 21, 54, 2, 43, 31)
  countries &lt;- list('US', 'UK', 'China', 'US', 'Russia', 'UK', 'US', 'China')
  names(values) &lt;- countries
  </code></pre>
  
  <p>Then, values looks like:<code>('US' = 2, 'UK' = 8, 'China' = 3, 'US' = 21, 'Russia' = 54, 'UK' = 2, 'US' = 43, 'China' = 31)</code></p>
  
  <p>Is there a built-in function in R or some short way to add the values of the duplicates? 
  Meaning, to make values become: <code>('UK' = 10, 'China' = 34, 'Russia' = 54, 'US' = 66)</code>
  (The order doesn't matter though)</p>