Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing a list of arguments to plot in R

Tags:

list

plot

r

I would like to use the same arguments for several calls to plot. I tried to use a list (which can serve as a dictionary) :

a <- list(type="o",ylab="")
plot(x,y, a)

But it does not work :

Error in plot.xy(xy, type, ...) : invalid plot type 

Any suggestion ?

like image 674
alex_reader Avatar asked Mar 24 '23 01:03

alex_reader


1 Answers

Extending @baptiste's answer, you can use do.call like this:

x <- 1:10  # some data
y <- 10:1
do.call("plot", list(x,y, type="o", ylab=""))

Or setting the arguments in a list and call it a

a <- list(x,y, type="o", ylab="")
do.call(plot, a)
like image 113
Jilber Urbina Avatar answered Mar 31 '23 13:03

Jilber Urbina