title: How can I complete a data.table column with values from this column?
body: <p>I have a <code>data.table()</code> with the columns : <strong>city</strong>,<strong>month</strong>, <strong>year</strong> and <strong>gdp_per_capta</strong> - by year, its value repeat all months. (actually I have 30 more columns)</p>
  <p>My base is full fill from 2005 to 2018.
  But, to the year 2019, the gdp_per_capta has <strong>NA</strong>.</p>
  <p>I would like to put a value on it, this way: <em>2019 = (2018/2017) * 2018</em></p>
  <p>How can I do it?</p>
  <p><em>PS: How can I improve the title of this question?</em></p>
  <p>Example of my data:</p>
  <pre><code>structure(list(city = c(110001L, 110001L, 110001L, 110001L, 
                                        110001L, 110001L, 110001L, 110001L, 110001L, 110001L, 110001L, 
                                        110001L, 110037L, 110037L, 110037L, 110037L, 110037L, 110037L, 
                                        110037L, 110037L, 110037L, 110037L, 110037L, 110037L, 110040L, 
                                        110040L, 110040L, 110040L, 110040L, 110040L, 110040L, 110040L, 
                                        110040L, 110040L, 110040L, 110040L), month = c(&quot;01&quot;, &quot;04&quot;, &quot;07&quot;, 
                                                                                     &quot;10&quot;, &quot;02&quot;, &quot;05&quot;, &quot;08&quot;, &quot;11&quot;, &quot;03&quot;, &quot;06&quot;, &quot;09&quot;, &quot;12&quot;, &quot;01&quot;, &quot;04&quot;, 
                                                                                     &quot;07&quot;, &quot;10&quot;, &quot;02&quot;, &quot;05&quot;, &quot;08&quot;, &quot;11&quot;, &quot;03&quot;, &quot;06&quot;, &quot;09&quot;, &quot;12&quot;, &quot;01&quot;, 
                                                                                     &quot;04&quot;, &quot;07&quot;, &quot;10&quot;, &quot;02&quot;, &quot;05&quot;, &quot;08&quot;, &quot;11&quot;, &quot;03&quot;, &quot;06&quot;, &quot;09&quot;, &quot;12&quot;
                                        ), year = c(2017L, 2017L, 2017L, 2017L, 2018L, 2018L, 2018L, 2018L, 
                                                   2019L, 2019L, 2019L, 2019L, 2017L, 2017L, 2017L, 2017L, 2018L, 
                                                   2018L, 2018L, 2018L, 2019L, 2019L, 2019L, 2019L, 2017L, 2017L, 
                                                   2017L, 2017L, 2018L, 2018L, 2018L, 2018L, 2019L, 2019L, 2019L, 
                                                   2019L), gdp_per_capta = c(19081.43, 19081.43, 19081.43, 
                                                                                    19081.43, 21552.47, 21552.47, 21552.47, 21552.47, NA, NA, NA, 
                                                                                    NA, 23353.6, 23353.6, 23353.6, 23353.6, 21053.93, 21053.93, 21053.93, 
                                                                                    21053.93, NA, NA, NA, NA, 14699.7, 14699.7, 14699.7, 14699.7, 
                                                                                    15655.57, 15655.57, 15655.57, 15655.57, NA, NA, NA, NA)), row.names = c(NA, 
                                                                                                                                                            -36L), class = c(&quot;data.table&quot;, &quot;data.frame&quot;))
  </code></pre>
  <p>My expected result is in red:
  <a href="https://i.stack.imgur.com/tzOjd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tzOjd.png" alt="enter image description here" /></a></p>