title: Sum Product of a list in dataframe by Order id in R
body: <p>I am doing a project which is similar to Uber Eat. I want to create new column in a data frame to calculate sub-total of these orders but because the class of each column is &quot;list&quot;, R is not allowing me to do that. Do you know any ways to do it.</p>
  <p>Thank you</p>
  <pre><code>a = c(1,2,3)
  b = 1:2
  c = (3,1)
  
  
  P1 = c(12,13,4)
  P2 = c(2,4)
  P3 = c(12,1)
  
  #My given dataframe will be:
  Order  | Price   | Sub-total
  a      | P1      |   sum(a*P1)
  b      | P2      |   sum(b*P2)
  c      |  P3     |    sum(c*P3)
  
  
  </code></pre>
  <p><strong>Expect output:</strong>
  Subtotal = [50, 10, 37]</p>
  <p>Please see the attached image to understand my dataframe
  <a href="https://i.stack.imgur.com/CVO1Z.png" rel="nofollow noreferrer">My dataframe</a></p>
  <p>My goal is how to compute a<em>P1, b</em>P2, c<em>P3 and then total sum of a</em>P1....</p>