title: Converting "NA" within a .csv file that has characters in the columns
body: <p>I am trying to format my data to be used in a multi-state model (program MARK).  My <code>.csv</code> file has birds detected at site &quot;R&quot; at a specific date and time. So, I need the <code>NA</code> within the columns to be replaced with <code>0</code> for not detected at that date and time.</p>
  <pre class="lang-r prettyprint-override"><code>REEDoutput.data &lt;- read.csv(&quot;REEDoutput.data.csv&quot;, header=TRUE)
  </code></pre>
  <p>Re-shape data table for MARK(TEST)</p>
  <pre class="lang-r prettyprint-override"><code>junk &lt;- melt(REEDoutput.data, id.var = c(&quot;id&quot;, &quot;ts&quot;), measure.var = &quot;num.det&quot;)
  
  y &lt;- cast(junk,id ~ts)
  y[is.na(y)] &lt;- 0
  </code></pre>
  <p>Warning messages are:</p>
  <blockquote>
  <ol>
  <li>In <code>[&lt;-.factor</code>(<code>*tmp*</code>, thisvar, value = 0) :
  invalid factor level, NA generated</li>
  <li>In <code>[&lt;-.factor</code>(<code>*tmp*</code>, thisvar, value = 0) :
  invalid factor level, NA generated</li>
  </ol>
  </blockquote>
  <p>I tried:</p>
  <pre class="lang-r prettyprint-override"><code>REEDoutput.data &lt;- read.csv(&quot;REEDoutput.data.csv&quot;, na.strings = &quot;NA&quot;, 
                              header = TRUE)
  </code></pre>
  <pre class="lang-r prettyprint-override"><code>REEDoutput.data &lt;- read.csv(&quot;REEDoutput.data.csv&quot;,  stringsAsFactors = FALSE, 
                              na.strings = &quot;NA&quot;, header = TRUE)
  </code></pre>
  <pre class="lang-r prettyprint-override"><code>REEDoutput.data &lt;- read.csv(&quot;REEDoutput.data.csv&quot;, stringsAsFactors = FALSE, 
                              header = TRUE)
  </code></pre>
  <p>All of which still give me the warning message</p>