title: Dealing with mistakes in recording the dataset in R
body: <p>I have a dataset that has a rather complicated problem. It includes 600,000 observations. The main issue is related to the data collection process. As an example I provided the following dataset that has  similar structure to the real datast I have in hand:</p>
  <pre><code>df &lt;- data.frame(row_number = c(1,2,3,4,5,6,7,8,9), 
                  date = c(&quot;2020-01-01&quot;, &quot;2020-01-01&quot;,&quot;2020-01-01&quot;,&quot;2020-01-02&quot;,&quot;2020-01-02&quot;,&quot;2020-01-02&quot;,&quot;2020-01-03&quot;,&quot;2020-01-03&quot;,&quot;2020-01-03&quot;),
                  time = c(&quot;01:00:00&quot;,&quot;09:00:00&quot;,&quot;17:00:00&quot;, &quot;09:00:00&quot;,&quot;01:00:00&quot;,&quot;17:00:00&quot;, &quot;01:00:00&quot;,&quot;NA&quot;,&quot;09:00:00&quot;),
                  order = c(1,2,3,1,2,3,1,2,3), 
                  value = c(10,20,30,40,10,20,30,NA,50)
  </code></pre>
  <p>I know in each day the data was recorded 3 times (order variable). That is in each day, the first time in which the data was recorded was 1:00:00, the second time in which the data was recorded was 09:00:00 and the last time in which the data was recorded was 17:00:00.</p>
  <p>However, the person who collected data has made mistakes. For instance, in row_num 4, the time is supposed to be 01:00:00, however, the data collector recorded 09:00:00.
  Also, in row number 8 I expect the time should be 9:00:00, however, since there was no information was recorded in value, the person did not fill that row and rather recorded the time to be 09:00:00 at order number 3 while it is expected that the time in order number 3 is 17:00:00.</p>
  <p>Given the fact that we know the order of the data collection, I was wondering if you have any solution to deal with such an issue in the dataset.</p>
  <p>Thanks in advance for your time.</p>