title: How to apply a function to certain columns while keeping the entire data frame?
body: <p>I am trying to assign NA to certain columns in a data frame when they equal 33.</p>
  
  <pre><code>df$A[df$A == 33] &lt;- NA
  df$B[df$B == 33] &lt;- NA
  df$C[df$C == 33] &lt;- NA
  </code></pre>
  
  <p>...and so on.</p>
  
  <p>I ran below codes</p>
  
  <pre><code>as.data.frame(apply(df[,c('A','B','C','D',...etc)], MARGIN=2, function(x) {ifelse(x==33, NA, x)}))
  </code></pre>
  
  <p>but this leaves me a data frame consists of only those specified columns. (I try to avoid cbind because it gets complicated when I actually need to do multiple cbind/rbind/merge at any step) 
  Is there a simpler way of doing it?</p>