title: adding new rows and values in R based on certain conditions
body: <p>I have some time series data by quarter, which are based on actuals.</p>
  <p>Let's say it looks something like this.</p>
  <pre><code>df_actuals &lt;- tibble(year=c(2018, 2018, 2018, 2018, 2019, 2019, 2019, 2019, 2020),
               quarter=c(1, 2, 3, 4, 1, 2, 3, 4, 1),
               value=c(10, 12, 10, 8, 9, 17, 11, 14, 15)
               )
  </code></pre>
  <p>Then I also have some projections, which are growth rates, that cover the same time period as well as into the future.</p>
  <pre><code>df_projections &lt;- tibble(year=c(2018, 2019, 2020, 2021),
                        annual_growth=c(.026, .031, .017, .019))
  </code></pre>
  <p>I want a dataframe that covers 2018-2021 at the year level using actuals from df_actuals for years with all 4 quarters of values. For any years with only some or no quarters of actual data, it instead applies the projected growth_rates from df_projections to calculate projected values through the final year of projections (which is currently 2021 but will eventually be 2022, 2023, etc.).</p>
  <p>The end result would look something like this ideally.</p>
  <pre><code>year value
  2018 10.00
  2019 12.75
  2020 12.97
  2021 13.21
  </code></pre>
  <p>Is something like this possible in a straightforward way?</p>