title: Trying to replace pattern in data frame, but I'm getting wrong output possibly due to column classes
body: <p>I have a data frame like the following, where columns 2 and 3 are factors.</p>
  
  <pre><code>radio &lt;- data.frame(id = 1:6, snp1 = c("C/T", "C/T", "C/T", "Not aplif", "C/T", "Not amplf"), snp2 = c("A/G", "C/T", "A/G", "Not amplif", "C/T", "C/T"))
  </code></pre>
  
  <p>I wanna replace every "Not amplif" with "NOT AMPLIFIED", but notice that I have typos in this string, the only part always correct is the "Not". So I tried the following:</p>
  
  <pre><code>radio[ ,c(2,3)][grep("Not", radio[ ,c(2,3)], ignore.case = TRUE), ] &lt;- "NOT AMPLIFIED"
  </code></pre>
  
  <p>But that gives me an error possibly because I'm dealing with factors. Then I tried to convert it to characters.</p>
  
  <pre><code>radio[ ,c(2,3)] = lapply(radio[ ,c(2,3)], as.character)
  </code></pre>
  
  <p>I tried the replacement step again, but now I replace the entire rows with "NOT AMPLIFIED", not only my target strings.</p>
  
  <p>Please, help.</p>