title: Appending a data frame with for if and else statements or how do put print in dataframe
body: <p>How do I put what I printed in a dataframe with a for loop and if else statements?
  Basically, this code:</p>
  
  <pre><code>list&lt;-c("10","20","5")
  for (j in 1:3){
    if (list[j] &lt; 8) 
      print("Greater")
    else print("Less")
  })
  #[1] "Less"
  #[1] "Less"
  #[1] "Greater"
  </code></pre>
  
  <p>Or should it be something more like this? </p>
  
  <pre><code>f3 &lt;- function(n){
    df &lt;- data.frame(x = numeric(n), y = character(n), stringsAsFactors = FALSE)
    for(j in 1:3){
      if (list[j] &lt; 8)
      df$x[j] &lt;- j
      df$y[j] &lt;- toString(Greater)
      else
      df$y[j] &lt;- toString(Less)
    }
    df
  }
  </code></pre>