title: Paste multiple columns together
body: <p>I have a bunch of columns in a dataframe which I want to paste together (seperated by "-") as follows:</p>
  
  <pre><code>data &lt;- data.frame('a' = 1:3, 
                     'b' = c('a','b','c'), 
                     'c' = c('d', 'e', 'f'), 
                     'd' = c('g', 'h', 'i'))
  i.e.     
       a   b   c  d  
       1   a   d   g  
       2   b   e   h  
       3   c   f   i  
  </code></pre>
  
  <p>Which I want to become:  </p>
  
  <pre><code>a x  
  1 a-d-g  
  2 b-e-h  
  3 c-f-i  
  </code></pre>
  
  <p>I could normally do this with:</p>
  
  <pre><code>within(data, x &lt;- paste(b,c,d,sep='-'))
  </code></pre>
  
  <p>and then removing the old columns, but unfortunately I do not know the names of the columns specifically, only a collective name for all of the columns, e.g. I would know that <code>cols &lt;- c('b','c','d')</code>  </p>
  
  <p>Does anyone know a way of doing this?</p>