Before you mark as dup, I know about [Use character string as function argument](https://stackoverflow.com/questions/7836972/use-character-string-as-function-argument?noredirect=1&lq=1), 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 `+` (think `ggplot2`).

(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).

This has been my process:

#### So let's reproduce this example:

```
library(condformat)
condformat(iris[c(1:5,70:75, 120:125),]) +
   rule_fill_discrete(Species) +
   rule_fill_discrete(Petal.Width) 

```

[![enter image description here](https://i.stack.imgur.com/x1FRR.png)](https://i.stack.imgur.com/x1FRR.png)

#### I would like to be able to pass the two `rule_fill_discrete()` functions dynamically (in my real use-case I have a variable number of possible inputs and it's not possible to hardcode these in).

#### First, create a function to generalize:

```
PlotSeries <- function(x){
   b=NULL
   for (i in 1:length(x)){
     a <- paste('rule_fill_discrete(',x[i],')',sep="")
     b <- paste(paste(b,a,sep="+")) 
     }
   b <- gsub("^\\+","",b)
   eval(parse(text = b))
 }

```

#### Which works with one argument

```
condformat(iris[c(1:5,70:75, 120:125),]) +
   PlotSeries("Species")

```

#### But not if we pass two arguments:

```
condformat(iris[c(1:5,70:75, 120:125),]) +
   PlotSeries(c("Species","Petal.Width"))

```

> 
> Error in rule\_fill\_discrete(Species) + rule\_fill\_discrete(Petal.Width) : 
>  non-numeric argument to binary operator
> 
> 
> 

#### It will work if we call each individually

```
condformat(iris[c(1:5,70:75, 120:125),]) +
   PlotSeries("Species") +
   PlotSeries("Petal.Width")

```

#### Which gives us an indication as to what the problem is... the fact that it doesn't like when the `rule_fill_discrete` statements are passed in as **one** statement. Let's test this:

```
condformat(iris[c(1:5,70:75, 120:125),]) +
   eval(rule_fill_discrete(Species) +
          rule_fill_discrete(Petal.Width) )

```

> 
> Error in rule\_fill\_discrete(Species) + rule\_fill\_discrete(Petal.Width) : 
>  non-numeric argument to binary operator
> 
> 
> 

#### Fails. But:

```
condformat(iris[c(1:5,70:75, 120:125),]) +
   eval(rule_fill_discrete(Species)) +
   eval(rule_fill_discrete(Petal.Width) )

```

#### This works. But we **need** 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:

```
Nasty <- "eval(rule_fill_discrete(Species)) eval(rule_fill_discrete(Petal.Width))"

 condformat(iris[c(1:5,70:75, 120:125),]) + Nasty                   #### FAIL

```

> 
> Error in `+.default`(condformat(iris[c(1:5, 70:75, 120:125), ]), Nasty) : 
>  non-numeric argument to binary operator
> 
> 
> 

```
condformat(iris[c(1:5,70:75, 120:125),]) + eval(Nasty)             #### FAIL

```

> 
> Error in `+.default`(condformat(iris[c(1:5, 70:75, 120:125), ]), eval(Nasty)) : 
>  non-numeric argument to binary operator
> 
> 
> 

```
condformat(iris[c(1:5,70:75, 120:125),]) + parse(text=Nasty)       #### FAIL

```

> 
> Error in `+.default`(condformat(iris[c(1:5, 70:75, 120:125), ]), parse(text = Nasty)) : 
>  non-numeric argument to binary operator
> 
> 
> 

```
condformat(iris[c(1:5,70:75, 120:125),]) + eval(parse(text=Nasty)) #### FAIL

```

> 
> Error in eval(rule\_fill\_discrete(Species)) + eval(rule\_fill\_discrete(Petal.Width)) : 
>  non-numeric argument to binary operator
> 
> 
> 

So how can we do it?