title: R - if-else applied to a list
body: <p>I am new to R, so it may be that some of concepts are not fully correct... 
  I have a set of files that I read into a list (here just shown the first 3 lines of each):</p>
  
  <pre><code>myfiles&lt;-lapply(list.files(".",pattern="tab",full.names=T),read.table,skip="#")
  myfiles
  [[1]]
         V1  V2         V3
  1   10001  33 -0.0499469
  2   30001  65  0.0991478
  3   50001  54  0.1564400
  
  [[2]]
         V1  V2        V3
  1   10001  62 0.0855260
  2   30001  74 0.1536640
  3   50001  71 0.1020960
  
  [[3]]
         V1  V2          V3
  1   10001  49 -0.04661360
  2   30001  65  0.16961500
  3   50001  61  0.07089600
  </code></pre>
  
  <p>I want to apply an ifelse condition in order to substitute values in columns and then return exactly the same list. However, when I do this:</p>
  
  <pre><code>myfiles&lt;-lapply(myfiles,function(x) ifelse(x$V2&gt;50, x$V3, NA))
  myfiles
  [[1]]
   [1]         NA  0.0991478  0.1564400
  
  [[2]]
   [1] 0.0855260 0.1536640 0.1020960
  
  [[3]]
   [1]          NA  0.16961500  0.07089600
  </code></pre>
  
  <p>it does in fact what I want to, but returns only the columns where the function was applied, and I want it to return the same list as before, with 3 columns (but with the substitutions).</p>
  
  <p>I guess there should be an easy way to do this with some variant of "apply", but I was not able to find it or solve it.</p>
  
  <p>Thanks</p>