Say we have this toy data:

```
temp <- data.frame(A=1:6, gr=c("A","A","A","B","B","B"))

```

I can easily create a plot as

```
lev <- c("A", "B")
ggplot()+geom_point(data=temp,aes(x=A, y=gr))+ylim(lev)

```

I get this
[![enter image description here](https://i.stack.imgur.com/RyLMQ.png)](https://i.stack.imgur.com/RyLMQ.png)

But I would like to convert it to a function in order to easily change the input parameters

```
myplot <- function(lev=lev) {ggplot()+geom_point(data=temp,aes(x=A, y=gr))+ylim(lev)}

```

But when I run 

```
lev <- c("B","A")
myplot()

```

I get this error:

> 
> Error in limits(c(...), "y") : promise already under evaluation:
>  recursive default argument reference or earlier problems?
> 
> 
> 

I've tried converting ylim to a factor, and using eval, but it doesn't work either.

I've tried parametrizing other things such as the input dataset and they work well, but I don't understand why ylim doesn't.

There is a question that speaks about a related problem with aes parameters  

[Pass function argument to ggplot label](https://stackoverflow.com/questions/35560191/pass-function-argument-to-ggplot-label) 

but its solution uses aes\_string and doesn't apply here.