title: multiplication with dataframes in r
body: <p>I have two dataframes. One is called data, like</p>
  
  <pre><code>data &lt;- data.frame(ID = c(1, 1, 2, 2 ),
             Number = c(1,2, 1, 2),
             Answer = c(1, 2, 3, 2 )
             )
  </code></pre>
  
  <p>The other is called weights, like </p>
  
  <pre><code>weights &lt;- data.frame ( Number=c(1,2), 
              weight1=c(0.5,1), 
              weight2=c(1, 1)
            )
  </code></pre>
  
  <p>What I want is to use Data$Answers to multiply Weights$weight based on Number (in both dataframes). The final results should be look like</p>
  
  <pre><code>  ID Number Answer Answer*Weights1  Answer*Weights2
  1  1      1      1   1*0.5             1*1
  2  1      2      2   2*1               2*1
  3  2      1      3   3*0.5             3*1
  4  2      2      2   2*1               2*1
  </code></pre>
  
  <p>How can I achieve it? Your inputs will be deeply appreciated. Thanks.</p>