title: How can I pass character strings as independent parameters after a `+`?
body: <p>Before you mark as dup, I know about <a href="https://stackoverflow.com/questions/7836972/use-character-string-as-function-argument?noredirect=1&amp;lq=1">Use character string as function argument</a>, but my use case is slightly different. I don't need to pass a parameter INSIDE the function, I would like to pass a dynamic number of parameters after a <code>+</code> (think <code>ggplot2</code>).</p>
  
  <p>(Note: Please don't format and remove the extra-looking ####, I have left them in so people can copy paste the code into R for simplicity).</p>
  
  <p>This has been my process:</p>
  
  <p>#### So let's reproduce this example:</p>
  
  <pre><code>library(condformat)
  condformat(iris[c(1:5,70:75, 120:125),]) +
     rule_fill_discrete(Species) +
     rule_fill_discrete(Petal.Width) 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/x1FRR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x1FRR.png" alt="enter image description here"></a></p>
  
  <p>#### I would like to be able to pass the two <code>rule_fill_discrete()</code> functions dynamically (in my real use-case I have a variable number of possible inputs and it's not possible to hardcode these in).</p>
  
  <p>#### First, create a function to generalize:</p>
  
  <pre><code>PlotSeries &lt;- function(x){
     b=NULL
     for (i in 1:length(x)){
       a &lt;- paste('rule_fill_discrete(',x[i],')',sep="")
       b &lt;- paste(paste(b,a,sep="+")) 
       }
     b &lt;- gsub("^\\+","",b)
     eval(parse(text = b))
   }
  </code></pre>
  
  <p>#### Which works with one argument</p>
  
  <pre><code>condformat(iris[c(1:5,70:75, 120:125),]) +
     PlotSeries("Species")
  </code></pre>
  
  <p>#### But not if we pass two arguments:</p>
  
  <pre><code>condformat(iris[c(1:5,70:75, 120:125),]) +
     PlotSeries(c("Species","Petal.Width"))
  </code></pre>
  
  <blockquote>
    <p>Error in rule_fill_discrete(Species) + rule_fill_discrete(Petal.Width) : 
      non-numeric argument to binary operator</p>
  </blockquote>
  
  <p>#### It will work if we call each individually</p>
  
  <pre><code>condformat(iris[c(1:5,70:75, 120:125),]) +
     PlotSeries("Species") +
     PlotSeries("Petal.Width")
  </code></pre>
  
  <p>#### Which gives us an indication as to what the problem is... the fact that it doesn't like when the <code>rule_fill_discrete</code> statements are passed in as <strong>one</strong> statement. Let's test this:</p>
  
  <pre><code>condformat(iris[c(1:5,70:75, 120:125),]) +
     eval(rule_fill_discrete(Species) +
            rule_fill_discrete(Petal.Width) )
  </code></pre>
  
  <blockquote>
    <p>Error in rule_fill_discrete(Species) + rule_fill_discrete(Petal.Width) : 
      non-numeric argument to binary operator</p>
  </blockquote>
  
  <p>#### Fails. But:</p>
  
  <pre><code>condformat(iris[c(1:5,70:75, 120:125),]) +
     eval(rule_fill_discrete(Species)) +
     eval(rule_fill_discrete(Petal.Width) )
  </code></pre>
  
  <p>#### This works. But we <strong>need</strong> to be able to pass in a GROUP of statements (that's kinda the whole point). So let's try to get the eval statements in:</p>
  
  <pre><code>Nasty &lt;- "eval(rule_fill_discrete(Species)) eval(rule_fill_discrete(Petal.Width))"
  
   condformat(iris[c(1:5,70:75, 120:125),]) + Nasty                   #### FAIL
  </code></pre>
  
  <blockquote>
    <p>Error in <code>+.default</code>(condformat(iris[c(1:5, 70:75, 120:125), ]), Nasty) : 
      non-numeric argument to binary operator</p>
  </blockquote>
  
  <pre><code>condformat(iris[c(1:5,70:75, 120:125),]) + eval(Nasty)             #### FAIL
  </code></pre>
  
  <blockquote>
    <p>Error in <code>+.default</code>(condformat(iris[c(1:5, 70:75, 120:125), ]), eval(Nasty)) : 
      non-numeric argument to binary operator</p>
  </blockquote>
  
  <pre><code>condformat(iris[c(1:5,70:75, 120:125),]) + parse(text=Nasty)       #### FAIL
  </code></pre>
  
  <blockquote>
    <p>Error in <code>+.default</code>(condformat(iris[c(1:5, 70:75, 120:125), ]), parse(text = Nasty)) : 
      non-numeric argument to binary operator</p>
  </blockquote>
  
  <pre><code>condformat(iris[c(1:5,70:75, 120:125),]) + eval(parse(text=Nasty)) #### FAIL
  </code></pre>
  
  <blockquote>
    <p>Error in eval(rule_fill_discrete(Species)) + eval(rule_fill_discrete(Petal.Width)) : 
      non-numeric argument to binary operator</p>
  </blockquote>
  
  <p>So how can we do it? </p>