title: passing an object in R, with multiple variable names, to order / sort a data frame
body: <p>I have a data frame say:</p>
  
  <pre><code>var1 &lt;- c(7,2,8,4,4)
  
  var2 &lt;- c('m' , 'f' , 'm' , 'f' , 'm')
  
  var3 &lt;- c('x' , 'x' , 'x' , 'y' , 'x')
  
  df &lt;- data.frame(var1 , var1 , var3)
  </code></pre>
  
  <p>Now I want to sort the data on var2, var3, var1, and I have an object:</p>
  
  <pre><code>var_sort &lt;- 'var2, var3, var1'
  </code></pre>
  
  <p>Which I extracted from another data frame.</p>
  
  <p>So I use the following code (dplyr):</p>
  
  <pre><code>sorted &lt;- df %&gt;%
              arrange(var_sort)
  </code></pre>
  
  <p>and get the following error:</p>
  
  <pre><code>Error: incorrect size (1), expecting :1439
  </code></pre>
  
  <p>I also tried the following, but only sorted on the first variable:</p>
  
  <pre><code>test &lt;- as.vector(strsplit(var_sort , ', '))
  
  sorted &lt;- df %&gt;%
    arrange_(.dots = test) 
  </code></pre>