title: Error: replacement has 1810947 rows and data has 1810956 (same each time) for pupil data
body: <p>I have a large dataframe in R (data) made up of 23 .gazedata files (one for each subject): </p>
  
  <pre><code>filenames &lt;- list.files("~/Desktop/DUT Analyses 2019", pattern = "*.gazedata", full.names = TRUE)
  ldf &lt;- lapply(filenames, read_tsv)
  data &lt;- do.call("rbind", ldf)
  </code></pre>
  
  <p>After creating factors and timing variables, I create the pupil variable, based on default validity parameters collected by the eye-tracker:</p>
  
  <pre><code>data$DiameterPupilLeftEye[data$ValidityLeftEye != 0] &lt;- NA
  data$DiameterPupilRightEye[data$ValidityRightEye != 0] &lt;- NA
  data$pupil = rowMeans(select(data, DiameterPupilLeftEye, DiameterPupilRightEye), na.rm = TRUE)
  </code></pre>
  
  <p>Now, I need to create an interpolated pupil variable (pupil_inter) to interpolate values to a maximum gap of 4:</p>
  
  <pre><code>data$pupil_inter&lt;- na.approx(data$pupil, rule = 2, maxgap = 4)
  </code></pre>
  
  <p>However, the following error occurs:</p>
  
  <pre><code>Error in `$&lt;-.data.frame`(`*tmp*`, pupil_inter, value = c(4.2120165, 4.20966425,  : 
  
  
  replacement has 1810947 rows, data has 1810956
  </code></pre>
  
  <p>These row amounts are exactly the same every time.</p>
  
  <p><strong><em>Crucially, if I exclude subjects 22 &amp; 23 .gazedata files from the pre-processing, the latter code works and there is no error</em></strong></p>
  
  <p>I have tried identifying an existing "replacement has [x] rows, data has [y]" problem to help with my specific issue, but can't find a relevant solution. All .gazedata files were collected using the same hardware and software.</p>
  
  <p>The error persists, even when successfully creating a null pupil_inter variable first, using the following code:</p>
  
  <pre><code>data$pupil_inter &lt;- NA
  </code></pre>
  
  <p>Thanks in advance for any advice offered.</p>