title: Replace values in list
body: <p>I have a nested list, which could look something like this:</p>
  
  <pre><code>characlist&lt;-list(list(c(1,2,3,4)),c(1,3,2,NA))
  </code></pre>
  
  <p>Next, I want to replace all values equal to one with NA. I tried the following, but it produces an error:</p>
  
  <pre><code>lapply(characlist,function(x) ifelse(x==1,NA,x))
  
  Error in ifelse(x == 1, NA, x) : 
    (list) object cannot be coerced to type 'double' 
  </code></pre>
  
  <p>Can someone tell me what's wrong with the code?</p>