title: R studio - How to group data in a panel by year and sum them
body: <p>I have a panel dataset for 20 years and 10 companies. </p>
  
  <p>For every company I have data on sales in Europe and the US.</p>
  
  <p>I would like to plot the overall sales in Europe and the US for every year.</p>
  
  <p>Basically, I need to sum the figure from every company for every year for the respective variable. </p>
  
  <p>How should I do that?</p>
  
  <p>Thanks everybody! I solved the problem usign group_by.</p>
  
  <pre><code>USsales &lt;- data %&gt;% group_by(Year) %&gt;% summarize(tot_USsales = sum(USsales, na.rm = TRUE))
  
  Europesales &lt;- data %&gt;% group_by(Year) %&gt;% summarize(tot_Eursales = sum(Eursales, na.rm = TRUE))
  
  netsales &lt;- merge(Europesales, USsales, by="Year")
  </code></pre>
  
  <p>Then I just plot it with ggplot.</p>
  
  <p>Thank you guys</p>