title: Impute NA values in column such that column sum and reference value is minimized in R
body: <p>I have a dataframe in R as below:</p>
  
  <pre><code>structure(list(Sales = c(1, 0, 4, 4, 2, 3, 3, 0, 2, 2), Txn_count = c(1, 
  0, 1, 2, 1, 2, 1, 0, 1, 1), VPP = c(1, NaN, 4, 2, 2, 1.5, 3, 
  NaN, 2, 2), prob = c(0.99, 0.81, 0.7, 0.8, 0.47, 0.59, 0.75, 
  0.99, 0.53, 0.72), row_Sales = c(0.99, NaN, 2.8, 1.6, 0.94, 0.885, 
  2.25, NaN, 1.06, 1.44)), row.names = c(NA, -10L), class = "data.frame")
  </code></pre>
  
  <p>Column VPP (Value per purchase) is calculated as Sales/Transaction for each row.</p>
  
  <p>I have <strong>sales_actual_vpp</strong> calculated as </p>
  
  <pre><code>sum(probabilities)*[sum(sales)/sum(transaction)]
  </code></pre>
  
  <p>i.e.</p>
  
  <pre><code>sum(column D)*[sum(column A)/sum(column B)]
  </code></pre>
  
  <p>This gives value as <strong>15.435</strong></p>
  
  <p>Now, I want to impute NA values in column <code>row_Sales</code> such that difference between <code>sales_actual_vpp</code>  and <code>sum(column row_Sales)</code> after imputation is minimized. <strong>Note that all NA values will be replaced by same value so that difference is still minimum</strong></p>
  
  <p>How can I achieve this in R using solver ?</p>