title: Error: In storage.mode(x) <- "double" : NAs introduced by coercion
body: <p>I'm new to R, but I'm trying to estimate a missing value in a large microarray dataset using <code>impute.knn()</code> from library(impute) using 6 nearest neighbors. </p>
  
  <p>Here's an example: </p>
  
  <pre><code>seq1 &lt;- seq(1:12)
  mat1 &lt;- matrix(seq1, 3)
  mat1[2,2] &lt;- "NA"
  impute.knn(mat1, k=6)
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Error in knnimp.internal(x, k, imiss, irmiss, p, n, maxp = maxp) : 
  NA/NaN/Inf in foreign function call (arg 1)
  In addition: Warning message:
  In storage.mode(x) &lt;- "double" : NAs introduced by coercion
  </code></pre>
  
  <p>I've also tried the following:</p>
  
  <pre><code>impute.knn(mat1[2,2], k=6)
  </code></pre>
  
  <p>and I get the following error:</p>
  
  <pre><code>Error in rep(1, p) : invalid 'times' argument
  </code></pre>
  
  <p>My google-fu has been off today. Any suggestions to why I might be getting this error?</p>
  
  <p>edit: I've tried </p>
  
  <pre><code>mat1[2,2] &lt;- NA 
  </code></pre>
  
  <p>as James suggested, but I get a segmentation fault. Using </p>
  
  <pre><code>replace(mat1, mat1[2,2], NA) 
  </code></pre>
  
  <p>does not help either. Any other suggestions?</p>