title: For loop and lapply
body: <p>First, I used a <code>for loop</code> for a vector of numbers, it worked well.</p>
  <p>When I used <code>lapply</code> fucntion, the results was not I want. I only want one element within a list.</p>
  <p>This is my example</p>
  <pre><code># With for loop, the outcome is one vector of numbers
  x &lt;- c(0.2,0.5,0.03,0.006,0.08)
  p.value &lt;- NULL
  for (i in 1:length(x)){
  if(x[i] &gt; 0.5 p.value[i] &lt;- (1-x[i])*2
  else p.value[i] &lt;- x[i]*2
  
  # with lapply
  lapply(x, function(x) {if(x &gt; 0.5) p.value &lt;- (1-x)*2 else p.value &lt;- x*2
  </code></pre>
  <p>The outcome from <code>lapply</code> is the combination of same results. I kinda realizing the problem, but I dont know how to change my code. Any suggestions for this?</p>