title: get the average that need to match the condition of other columns in R
body: <p>Here's the data:</p>
  <pre><code>data &lt;-tibble::tribble(
            ~PROPNUM, ~initial_date,  ~third_date,  ~OIL,  ~GAS,   ~Prod_date,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  775L,    0L,  &quot;9/30/2011&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;, 2210L,  477L, &quot;10/31/2011&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;, 1455L, 1008L, &quot;11/30/2011&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;, 1054L,  875L, &quot;12/31/2011&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  992L, 3003L,  &quot;1/31/2012&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  828L,  745L,  &quot;2/29/2012&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  485L,  533L,  &quot;3/31/2012&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;, 1084L,  821L,  &quot;4/30/2012&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  677L,  623L,  &quot;5/31/2012&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  658L,  598L,  &quot;6/30/2012&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  643L,  624L,  &quot;7/31/2012&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  608L,  619L,  &quot;8/31/2012&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  559L,  561L,  &quot;9/30/2012&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  558L,  567L, &quot;10/31/2012&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  514L,  491L, &quot;11/30/2012&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  531L,  462L, &quot;12/31/2012&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  481L,  480L,  &quot;1/31/2013&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  436L,  424L,  &quot;2/28/2013&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  449L,  488L,  &quot;3/31/2013&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  429L,  495L,  &quot;4/30/2013&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  422L,  511L,  &quot;5/31/2013&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  395L,  497L,  &quot;6/30/2013&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  382L,  519L,  &quot;7/31/2013&quot;,
      &quot;49-005-61202&quot;,  &quot;2011-09-30&quot;, &quot;2011-11-30&quot;,  391L,  519L,  &quot;8/31/2013&quot;
      )
  </code></pre>
  <p>Thank you so much for the reply!</p>
  <p>I tested on my own data using AKrun and PaulS's method, but it's returning 0 obs . 2 variables, the warning I got is &quot;All formats failed to parse. No formats found. &quot;
  I uploaded the data again, this one should reproduce my problem.</p>