title: Iterate through columns in dplyr
body: <p>I am trying to iterate a function progressively through the columns of a database. What are the options available for this? Am I limited to a for loop or is there a dplyr approach or similarly intuitive code structure I can use?</p>
  
  <p>Essentially I have a matrix much much larger than the one constructed below, but of the same general structure. The first column explains which version to select as the refined datacollection, and then all the data that comprises each of these three versions.  </p>
  
  <pre><code>library(dplyr)
  
  # Function: creates a matrix of random strings, v = versionNumber
  matADv.maker &lt;- function (v){ 
      matADv &lt;- data.frame(matrix(sample(letters[1:26], 10), nrow = 5))
      colnames(matADv) &lt;- paste0("v", v, "_", letters[24:25])
      return(matADv)
  }
  
  set.seed(1)
  lvl &lt;- data.frame(c(as.integer(runif(5, 5, 8))))
  colnames(lvl) &lt;- "Level"
  matADv5 &lt;- matADv.maker(5)
  matADv6 &lt;- matADv.maker(6)
  matADv7 &lt;- matADv.maker(7)
  matComp &lt;- bind_cols(lvl, matADv5, matADv6, matADv7)
  matComp
  Source: local data frame [5 x 8]
  </code></pre>
  
  <blockquote>
  <pre><code>  rowname Level  v5_x  v5_y  v6_x  v6_y  v7_x  v7_y
      (chr) (int) (chr) (chr) (chr) (chr) (chr) (chr)
  1       1     5     x     e     m     t     k     z
  2       2     6     z     d     r     e     a     l
  3       3     6     p     n     x     z     j     x
  4       4     7     o     g     i     c     u     d
  5       5     5     b     s     y     u     h     o
  </code></pre>
  </blockquote>
  
  <p>I was wondering if there isn't instead some simple way to shuttle a function along the dataframe.</p>
  
  <p>Essentially, <em>How might I be able to iterate through columns by using dplyr or similar simpler constructions than for loops?</em></p>