title: Calculate the quarterly growth rate
body: <p>I tried to calculate the quarterly growth rate in sales for different stores. However, I group by my data several times until it became the following status:</p>
  <p>How can I generate the growth rate table based on this equation: (Q3-Q2)/Q2?</p>
  <p>The code I programmed so far is as follows. Thank you.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">Store</th>
  <th style="text-align: center;">Quarter</th>
  <th style="text-align: right;">Weekly_Sales</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">1</td>
  <td style="text-align: center;">Q2</td>
  <td style="text-align: right;">60428109</td>
  </tr>
  <tr>
  <td style="text-align: left;">1</td>
  <td style="text-align: center;">Q3</td>
  <td style="text-align: right;">20253948</td>
  </tr>
  <tr>
  <td style="text-align: left;">2</td>
  <td style="text-align: center;">Q2</td>
  <td style="text-align: right;">74356864</td>
  </tr>
  <tr>
  <td style="text-align: left;">2</td>
  <td style="text-align: center;">Q3</td>
  <td style="text-align: right;">24303355</td>
  </tr>
  <tr>
  <td style="text-align: left;">3</td>
  <td style="text-align: center;">Q2</td>
  <td style="text-align: right;">15459190</td>
  </tr>
  <tr>
  <td style="text-align: left;">3</td>
  <td style="text-align: center;">Q3</td>
  <td style="text-align: right;">5298005</td>
  </tr>
  <tr>
  <td style="text-align: left;">4</td>
  <td style="text-align: center;">Q2</td>
  <td style="text-align: right;">79302989</td>
  </tr>
  <tr>
  <td style="text-align: left;">4</td>
  <td style="text-align: center;">Q3</td>
  <td style="text-align: right;">27796792</td>
  </tr>
  <tr>
  <td style="text-align: left;">5</td>
  <td style="text-align: center;">Q2</td>
  <td style="text-align: right;">12523263</td>
  </tr>
  <tr>
  <td style="text-align: left;">5</td>
  <td style="text-align: center;">Q3</td>
  <td style="text-align: right;">4163791</td>
  </tr>
  </tbody>
  </table>
  </div>
  <pre class="lang-r prettyprint-override"><code>library(&quot;dplyr&quot;)
  library(&quot;lubridate&quot;)
  Walmart_data_set &lt;- read.csv(&quot;Walmart_Store_sales.csv&quot;)
  
  Walmart_data_set$Date &lt;- as.Date(Walmart_data_set$Date, &quot;%d-%m-%Y&quot;)
  Walmart_data_set[&quot;Month&quot;] &lt;- month(Walmart_data_set$Date)
  Walmart_data_set[&quot;Quarter&quot;] &lt;- quarters(Walmart_data_set$Date)
  Walmart_data_set[&quot;Year&quot;] &lt;- format(Walmart_data_set$Date, format =&quot;%Y&quot;)
  
  
  Q23_2012_Sales&lt;- filter(Walmart_data_set, Year == &quot;2012&quot; &amp; Quarter == &quot;Q3&quot; | Quarter == &quot;Q2&quot;)
  Sales_Store_quarter = Q23_2012_Sales %&gt;% group_by(Store, Quarter)  %&gt;%
    summarise(Weekly_Sales = sum(Weekly_Sales),
              .groups = 'drop')
  </code></pre>