title: How can I process dataframe using for loop in R?
body: <pre><code>### Part1 --------------------------------------------------------------
  data5 &lt;- data.frame(late_AMD_1st=c(1, NA, 3, 4), RVO_1st=c(5, 6, NA, 8))
  # late_AMD_1st RVO_1st
  # 1            1       5
  # 2           NA       6
  # 3            3      NA
  # 4            4       8
  data5 &lt;- subset(data5, !(is.na(data5$late_AMD_1st)))
  data5 &lt;- subset(data5, !(is.na(data5$RVO_1st)))
  # data5
  # late_AMD_1st RVO_1st
  # 1            1       5
  # 4            4       8
  </code></pre>
  
  <pre><code>### Part2 --------------------------------------------------------------
  
  data5 &lt;- data.frame(late_AMD_1st=c(1, NA, 3, 4), RVO_1st=c(5, 6, NA, 8))
  col_name &lt;- c("late_AMD_1st", "RVO_1st")
  for (i in col_name){
    data5 &lt;- subset(data5, !(is.na(data5$i)))
  }
  # data5
  # [1] late_AMD_1st RVO_1st     
  # &lt;0 行&gt; (または長さ 0 の row.names) 
  </code></pre>
  
  <p>I want to do the same thing as Part1 in Part2. But somehow I get the different data.frame in Part2. Am I wrong in using for loops?</p>