title: R error: "New Column would leave holes after existing columns"
body: <p>I have two data frames, one is accuracy for a task and the other is response time (RT).  I'm trying to get only get the RT's for correct trials, rather than all trials.  I've made it so the incorrect trials in the accuracy table are displayed as NA, and when trying to make the corresponding cells NA in the RT table, I seem to be getting the error: </p>
  
  <pre><code>Error in `[&lt;-.data.frame`(`*tmp*`, which(is.na(ACC)), value = NA) : new columns would leave holes after existing columns
  </code></pre>
  
  <p>The code is fairly simple - I've tried it with randomly generated data and it seems to work just fine.  The code is as follows:</p>
  
  <h1>Open the files</h1>
  
  <pre><code>ACC &lt;- read_excel("PJ_ACC_TABLE.xlsx", sheet = 1)
  RT &lt;- read_excel("PJ_RT_TABLE.xlsx", sheet = 1)
  </code></pre>
  
  <h1>Change errors to NA</h1>
  
  <pre><code>ACC &lt;- ifelse(ACC&gt;0,1,NA)
  </code></pre>
  
  <h1>Change</h1>
  
  <pre><code>RT[which(is.na(ACC))] &lt;- NA
  </code></pre>
  
  <p>My ACC table looks something like: </p>
  
  <p><a href="https://i.stack.imgur.com/PpCBv.png" rel="nofollow noreferrer">ACC table</a></p>
  
  <p>While my RT table looks something like:</p>
  
  <p><a href="https://i.stack.imgur.com/zd2iK.png" rel="nofollow noreferrer">RT table</a></p>
  
  <p>I noticed that after I change the ACC table to include the NA's, it turns into a vector.</p>
  
  <p>Any help would be appreciated, thanks!</p>