Multiplication of different subsets with different data in R
<p>I have a large dataset, which I splitted up into subsets. For each subsets, I have to do the same calculations but with different numbers. Example:</p>

<pre><code>Main Table
x a b c d
A 1 2 4 5 
A 4 5 1 7
A 3 5 6 2
B 4 5 2 9
B 3 5 2 8
C 4 2 5 2
C 1 9 6 9
C 1 2 3 4
C 6 3 6 2

 Additional Table for A
  a b c d
A 5 1 6 1

Additional Table for B
  a b c d
B 1 5 2 6

Additional Table for C
  a c c d
C 8 2 4 1
</code></pre>

<p>I need to multiply all rows A in the Main Table with the values from Additional Table for A, all rows B in the Main table with the values from B and all rows B in the main table with values from C. It is completely fine to merge the additional tables into a combined one, if this makes the solution easier.</p>

<p>I thought about a for-loop but I am not able to put the different multiplicators (from the Additional Tables) into the code. Since there is a large number of subgroups, coding each multiplication manually should be avoided. How do I do this multiplications?</p>