title: How to iterate over dataframe using character vector and calculate the mean for matching items in R
body: <p>I have a <code>character vector</code> and want to iterate over some <code>dataframes</code> and consider the matching characters and note the corresponding values and finally take the average of all the values and store in results in a new <code>dataframe</code>.</p>
  <p>Below is the sample example:</p>
  <pre><code>ip &lt;- c(&quot;John&quot;, &quot;Amanda&quot;, &quot;Aaron&quot;, &quot;Peter&quot;, &quot;Jolie&quot;)
  
  dfs &lt;- data.frame(&quot;names&quot; = c('John','Peter','jucy'), &quot;value1&quot; = c(21, 24, 26), &quot;value2&quot; = c(20, 23, 32))
  dfg &lt;- data.frame(&quot;names&quot; = c('Justin','John','Jill'), &quot;value1&quot; = c(35, 11, 10), &quot;value2&quot; = c(10, 28, 27))
  dft &lt;- data.frame(&quot;names&quot; = c('Louis','Chan','John'), &quot;value1&quot; = c(42, 74, 26), &quot;value2&quot; = c(26, 53, 54))
  dfr &lt;- data.frame(&quot;names&quot; = c('Ale','Terry','Tom'), &quot;value1&quot; = c(61, 34, 76), &quot;value2&quot; = c(28, 63, 38))
  dfm &lt;- data.frame(&quot;names&quot; = c('Sam','Jolie','Peter'), &quot;value1&quot; = c(11, 84, 86), &quot;value2&quot; = c(50, 13, 68))
  </code></pre>
  <p>Expected output:</p>
  <pre><code>names  value1  value2
  John    19.33  34
  Peter   55     45.5
  Jolie   84     13
  </code></pre>
  <p>For John <code>value1 = mean(c(21, 11, 26)) = 19.33</code> and <code>value2 = mean(c(20, 28, 54)) = 34</code></p>
  <p>Similarly, for Peter <code>value1 = mean(c(24, 86)) = 55</code> and <code>value2 = mean(c(23,68)) = 45.5</code></p>